mirror of https://gerrit.osmocom.org/asn1c
remove undefined behavior
This commit is contained in:
parent
a9e63373e5
commit
38a91df0fc
|
@ -633,13 +633,14 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
if(asn_ulong2INTEGER(st, uvalue))
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
unsigned long svalue = 0;
|
||||
unsigned long uvalue = 0;
|
||||
long svalue;
|
||||
if(uper_get_constrained_whole_number(pd,
|
||||
&svalue, ct->range_bits))
|
||||
&uvalue, ct->range_bits))
|
||||
ASN__DECODE_STARVED;
|
||||
ASN_DEBUG("Got value %ld + low %ld",
|
||||
svalue, ct->lower_bound);
|
||||
svalue += ct->lower_bound;
|
||||
ASN_DEBUG("Got value %lu + low %ld",
|
||||
uvalue, ct->lower_bound);
|
||||
svalue = ct->lower_bound + (long)uvalue;
|
||||
if(asn_long2INTEGER(st, svalue))
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ asn_get_few_bits(asn_bit_data_t *pd, int nbits) {
|
|||
else if(off <= 24)
|
||||
accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off);
|
||||
else if(off <= 31)
|
||||
accum = ((buf[0] << 24) + (buf[1] << 16)
|
||||
accum = (((uint32_t)buf[0] << 24) + (buf[1] << 16)
|
||||
+ (buf[2] << 8) + (buf[3])) >> (32 - off);
|
||||
else if(nbits <= 31) {
|
||||
asn_bit_data_t tpd = *pd;
|
||||
|
|
Loading…
Reference in New Issue