Commit 38a91df0 authored by Lev Walkin's avatar Lev Walkin

remove undefined behavior

parent a9e63373
...@@ -633,13 +633,14 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t ...@@ -633,13 +633,14 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
if(asn_ulong2INTEGER(st, uvalue)) if(asn_ulong2INTEGER(st, uvalue))
ASN__DECODE_FAILED; ASN__DECODE_FAILED;
} else { } else {
unsigned long svalue = 0; unsigned long uvalue = 0;
long svalue;
if(uper_get_constrained_whole_number(pd, if(uper_get_constrained_whole_number(pd,
&svalue, ct->range_bits)) &uvalue, ct->range_bits))
ASN__DECODE_STARVED; ASN__DECODE_STARVED;
ASN_DEBUG("Got value %ld + low %ld", ASN_DEBUG("Got value %lu + low %ld",
svalue, ct->lower_bound); uvalue, ct->lower_bound);
svalue += ct->lower_bound; svalue = ct->lower_bound + (long)uvalue;
if(asn_long2INTEGER(st, svalue)) if(asn_long2INTEGER(st, svalue))
ASN__DECODE_FAILED; ASN__DECODE_FAILED;
} }
......
...@@ -86,7 +86,7 @@ asn_get_few_bits(asn_bit_data_t *pd, int nbits) { ...@@ -86,7 +86,7 @@ asn_get_few_bits(asn_bit_data_t *pd, int nbits) {
else if(off <= 24) else if(off <= 24)
accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off); accum = ((buf[0] << 16) + (buf[1] << 8) + buf[2]) >> (24 - off);
else if(off <= 31) 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); + (buf[2] << 8) + (buf[3])) >> (32 - off);
else if(nbits <= 31) { else if(nbits <= 31) {
asn_bit_data_t tpd = *pd; asn_bit_data_t tpd = *pd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment