fix the 32bit S1AP problem

This commit is contained in:
Sukchan Lee 2018-03-14 13:40:45 +09:00
parent d881f8c2ed
commit 637d8613ba
2 changed files with 12 additions and 4 deletions

View File

@ -324,6 +324,8 @@ INTEGER_st_prealloc(INTEGER_t *st, int min_size) {
static enum xer_pbd_rval
INTEGER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
const void *chunk_buf, size_t chunk_size) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
INTEGER_t *st = (INTEGER_t *)sptr;
intmax_t dec_value;
intmax_t hex_value = 0;
@ -505,7 +507,9 @@ INTEGER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
/* The last symbol encountered was a digit. */
switch(asn_strtoimax_lim(dec_value_start, &dec_value_end, &dec_value)) {
case ASN_STRTOX_OK:
if(dec_value >= LONG_MIN && dec_value <= LONG_MAX) {
if(specs && specs->field_unsigned && dec_value <= ULONG_MAX) {
break;
} else if(dec_value >= LONG_MIN && dec_value <= LONG_MAX) {
break;
} else {
/*
@ -879,7 +883,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
value += ct->lower_bound;
if((specs && specs->field_unsigned)
? asn_uint642INTEGER(st, value)
? asn_uint642INTEGER(st, (unsigned long)value)
: asn_int642INTEGER(st, value))
ASN__DECODE_FAILED;
ASN_DEBUG("Got value %ld + low %ld",
@ -1044,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);
@ -1056,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;

View File

@ -25,7 +25,11 @@ typedef struct asn_per_constraint_s {
int range_bits; /* Full number of bits in the range */
int effective_bits; /* Effective bits */
long lower_bound; /* "lb" value */
#if 0 /* modified by acetcom */
long upper_bound; /* "ub" value */
#else
int64_t upper_bound; /* "ub" value */
#endif
} asn_per_constraint_t;
typedef struct asn_per_constraints_s {
asn_per_constraint_t value;