Commit 1cf4225c authored by mouse07410's avatar mouse07410

Add (some?) missing checks to PER encoding of unsigned integer (addressing

deficiencies of vlm/#260).
parent 8a29c8e5
...@@ -778,6 +778,14 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td, ...@@ -778,6 +778,14 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
ASN_DEBUG("Encoding integer %ld (%lu) with range %d bits", ASN_DEBUG("Encoding integer %ld (%lu) with range %d bits",
value, value - ct->lower_bound, ct->range_bits); value, value - ct->lower_bound, ct->range_bits);
if(specs && specs->field_unsigned) { if(specs && specs->field_unsigned) {
if ( ((unsigned long)ct->lower_bound > (unsigned long)(ct->upper_bound)
|| ((unsigned long)value < (unsigned long)ct->lower_bound))
|| ((unsigned long)value > (unsigned long)ct->upper_bound)
) {
ASN_DEBUG("Value %lu to-be-encoded is outside the bounds [%lu, %lu]!",
value, ct->lower_bound, ct->upper_bound);
ASN__ENCODE_FAILED;
}
v = (unsigned long)value - (unsigned long)ct->lower_bound; v = (unsigned long)value - (unsigned long)ct->lower_bound;
} else { } else {
if(per_long_range_rebase(value, ct->lower_bound, ct->upper_bound, &v)) { if(per_long_range_rebase(value, ct->lower_bound, ct->upper_bound, &v)) {
......
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