Commit 100e6229 authored by Mouse's avatar Mouse

Committed "aper: workaround for undefined enumeration indexes" by Krzysztof...

Committed "aper: workaround for undefined enumeration indexes" by Krzysztof Witek <kwitek@kw-net.com>
commit a12c7fa47901bf6dee4cc21702efa6e7ecc1bb4f from vlm/asn1c #115
parent de0d9ead
...@@ -282,11 +282,19 @@ NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx, ...@@ -282,11 +282,19 @@ NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
/* /*
* X.691, #10.6: normally small non-negative whole number; * X.691, #10.6: normally small non-negative whole number;
*/ */
value = uper_get_nsnnwn(pd); //value = uper_get_nsnnwn(pd);
/* XXX handle indefinite index length > 64k */
value = aper_get_nsnnwn(pd, 65537);
if(value < 0) ASN__DECODE_STARVED; if(value < 0) ASN__DECODE_STARVED;
value += specs->extension - 1; value += specs->extension - 1;
if(value >= specs->map_count) //if(value >= specs->map_count)
ASN__DECODE_FAILED; // ASN__DECODE_FAILED;
if(value >= specs->map_count) {
ASN_DEBUG("Decoded unknown index value %s = %ld", td->name, value);
/* unknown index. Workaround => set the first enumeration value */
*native = specs->value2enum[0].nat_value;
return rval;
}
} }
*native = specs->value2enum[value].nat_value; *native = specs->value2enum[value].nat_value;
......
...@@ -396,7 +396,25 @@ aper_get_nsnnwn(asn_per_data_t *pd, int range) { ...@@ -396,7 +396,25 @@ aper_get_nsnnwn(asn_per_data_t *pd, int range) {
/* 2 bytes */ /* 2 bytes */
bytes = 2; bytes = 2;
} else { } else {
return -1; //return -1;
int length;
/* handle indefinite range */
length = per_get_few_bits(pd, 1);
if (length == 0)
return per_get_few_bits(pd, 6);
if (aper_get_align(pd) < 0)
return -1;
length = per_get_few_bits(pd, 8);
/* the length is not likely to be that big */
if (length > 4)
return -1;
value = 0;
if (per_get_many_bits(pd, (uint8_t *)&value, 0, length * 8) < 0)
return -1;
return value;
} }
if (aper_get_align(pd) < 0) if (aper_get_align(pd) < 0)
return -1; return -1;
......
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