Commit 60ee1206 authored by Pau Espin Pedrol's avatar Pau Espin Pedrol Committed by Mouse

tests-skeletons/check-APER-support: Showcase bug in aper_put_nsnnwn() passing val>range

This patch introduces a test uncovering a bug when tyring to use
aper_put_length() with a value bigger than its range.
A follow up commit fixes the bug.
parent 6afb6e82
......@@ -79,8 +79,25 @@ check_round_trips_range65536() {
check_round_trip(65536, 65536);
}
/*
* Checks that Encoding a value greater than range fails.
*/
static void
check_encode_number_greater_than_range() {
asn_per_outp_t po;
int range = 6500;
size_t length = 6503;
memset(&po, 0, sizeof(po));
po.buffer = po.tmpspace;
po.nbits = 8 * sizeof(po.tmpspace);
ssize_t may_write = aper_put_length(&po, range, length, NULL);
assert(may_write >= 0); /* BUG, this should fail! */
}
int main() {
check_round_trips_range65536();
check_encode_number_greater_than_range();
}
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