Skip to content

Commit

Permalink
aper: Fix INTEGER encode on 32bit platforms
Browse files Browse the repository at this point in the history
On i686 the long is 4 bytes and the right shift with more then 32 bits
is probably an undefined behaviour

See vlm#185 (comment)
  • Loading branch information
velichkov authored and mouse07410 committed Mar 14, 2018
1 parent 3af2489 commit fa5e1c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions skeletons/INTEGER.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
ASN__ENCODE_FAILED;
} else {
/* TODO: extend to >64 bits */
long v64 = v;
int64_t v64 = v;
int i, j;
int max_range_bytes = (ct->range_bits >> 3) +
(((ct->range_bits % 8) > 0) ? 1 : 0);
Expand All @@ -1060,7 +1060,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}

for (j = sizeof(int64_t) -1; j != 0; j--) {
uint8_t val;
int64_t val;
val = v64 >> (j * 8);
if (val != 0)
break;
Expand Down

0 comments on commit fa5e1c5

Please sign in to comment.