neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libasn1c/+/37984?usp=email )
Change subject: coverity CID#57681
......................................................................
coverity CID#57681
Make sure that bits_unused cannot subtract more bits than present in
st->size.
Especially when st->size == 0, this ensures that sizeinunits is also 0,
and that a st->size == 0 hence never enters the while (sizeinunits)
loop.
Change-Id: Ic8e3f5e24541989b79826de2942e5e6560079028
---
M src/OCTET_STRING.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libasn1c refs/changes/84/37984/1
diff --git a/src/OCTET_STRING.c b/src/OCTET_STRING.c
index 3e424e7..9d2e817 100644
--- a/src/OCTET_STRING.c
+++ b/src/OCTET_STRING.c
@@ -1859,6 +1859,7 @@
unsigned int unit_bits;
unsigned int canonical_unit_bits;
unsigned int sizeinunits;
+ unsigned int unused;
const uint8_t *buf;
int ret;
enum {
@@ -1888,7 +1889,11 @@
case ASN_OSUBV_BIT:
canonical_unit_bits = unit_bits = 1;
bpc = OS__BPC_BIT;
- sizeinunits = st->size * 8 - (st->bits_unused & 0x07);
+ sizeinunits = st->size * 8;
+ /* make sure sizeinunits cannot wrap past zero (especially when st->size == 0). */
+ unused = st->bits_unused & 0x07;
+ if (unused <= sizeinunits)
+ sizeinunits -= unused;
ASN_DEBUG("BIT STRING of %d bytes",
sizeinunits);
break;
@@ -1994,6 +1999,9 @@
maySave, bpc, unit_bits,
cval->lower_bound, cval->upper_bound, pc);
} else {
+ /* coverity CID#57681: st->buf can be NULL, but above, we've verified that when st->buf == NULL,
+ * then also st->size == 0, and hence sizeinunits == 0, hence this 'while' will skip entirely,
+ * and hence it is safe to dereference buf here. */
ret = per_put_many_bits(po, buf, maySave * unit_bits);
}
if(ret) _ASN_ENCODE_FAILED;
--
To view, visit https://gerrit.osmocom.org/c/libasn1c/+/37984?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libasn1c
Gerrit-Branch: master
Gerrit-Change-Id: Ic8e3f5e24541989b79826de2942e5e6560079028
Gerrit-Change-Number: 37984
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Attention is currently required from: pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958?usp=email )
Change subject: s1gw: Initial StatsD support
......................................................................
Patch Set 2:
(2 comments)
File s1gw/S1GW_Tests.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958/comment/f9a54fd9_9ce9… :
PS2, Line 79: VirtHNBGW
copy-paste
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958/comment/6ec41f4c_6ba5… :
PS2, Line 112: f_new_ConnHdlrPars
[At least now] I don't really see the need for this function.
```
var ConnHdlrPars pars := valueof(t_ConnHdlrPars());
var ConnHdlrPars pars := f_new_ConnHdlrPars();
```
Does not worth it saving just a few chars...
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ib98c2fe68006a8d0f45de6966927b349a3b933ca
Gerrit-Change-Number: 37958
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 02 Sep 2024 20:38:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: daniel, laforge, pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37956?usp=email )
Change subject: StatsD_Checker: Allow building without VTY support
......................................................................
Patch Set 2: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37956?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I5421c76e4f303fd16d4db945a1c69910e40ac820
Gerrit-Change-Number: 37956
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 02 Sep 2024 19:34:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes