Commit fec0acc0 authored by Vasil Velichkov's avatar Vasil Velichkov

aper: Fix INTEGER encode on 32bit platforms

On i686 the long is 4 bytes and the right shift with more then 32 bits
is probably an undefined behaviour

See https://github.com/vlm/asn1c/issues/185#issuecomment-372546490
parent 4637e030
...@@ -1044,7 +1044,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td, ...@@ -1044,7 +1044,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
ASN__ENCODE_FAILED; ASN__ENCODE_FAILED;
} else { } else {
/* TODO: extend to >64 bits */ /* TODO: extend to >64 bits */
long v64 = v; int64_t v64 = v;
int i, j; int i, j;
int max_range_bytes = (ct->range_bits >> 3) + int max_range_bytes = (ct->range_bits >> 3) +
(((ct->range_bits % 8) > 0) ? 1 : 0); (((ct->range_bits % 8) > 0) ? 1 : 0);
...@@ -1056,7 +1056,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td, ...@@ -1056,7 +1056,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
} }
for (j = sizeof(int64_t) -1; j != 0; j--) { for (j = sizeof(int64_t) -1; j != 0; j--) {
uint8_t val; int64_t val;
val = v64 >> (j * 8); val = v64 >> (j * 8);
if (val != 0) if (val != 0)
break; break;
......
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