diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-03-31 22:08:36 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-03-31 22:08:36 +0200 |
commit | e7a2f753a91f9538d2d98df0bb3bdc11005bfc82 (patch) | |
tree | 1539f4399fe4091d31d2421d05425dd0e4d2b958 /tests | |
parent | 3873c6a49122e3f15901646e072938557acd3f8e (diff) | |
download | libtasn1-e7a2f753a91f9538d2d98df0bb3bdc11005bfc82.tar.gz libtasn1-e7a2f753a91f9538d2d98df0bb3bdc11005bfc82.tar.bz2 libtasn1-e7a2f753a91f9538d2d98df0bb3bdc11005bfc82.zip |
Added additional test case
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Test_overflow.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/Test_overflow.c b/tests/Test_overflow.c index bd6ede7..cbf9381 100644 --- a/tests/Test_overflow.c +++ b/tests/Test_overflow.c @@ -99,6 +99,30 @@ main (void) /* Test that values larger than would fit in the input string are rejected. This problem was fixed in libtasn1 2.12. */ { + unsigned long num = 1073741824; + unsigned char der[20]; + int der_len; + long l; + int len; + + asn1_length_der (num, der, &der_len); + + der_len = sizeof(der); + l = asn1_get_length_der (der, der_len, &len); + + if (l == -4L) + puts ("OK: asn1_get_length_der overflow-large1"); + else + { + printf ("ERROR: asn1_get_length_der overflow-large1 (l %ld len %d)\n", l, + len); + return 1; + } + } + + /* Test that values larger than would fit in the input string are + rejected. This problem was fixed in libtasn1 2.12. */ + { unsigned long num = 2147483647; unsigned char der[20]; int der_len; @@ -111,10 +135,10 @@ main (void) l = asn1_get_length_der (der, der_len, &len); if (l == -2L) - puts ("OK: asn1_get_length_der overflow-large"); + puts ("OK: asn1_get_length_der overflow-large2"); else { - printf ("ERROR: asn1_get_length_der overflow-large (l %ld len %d)\n", l, + printf ("ERROR: asn1_get_length_der overflow-large2 (l %ld len %d)\n", l, len); return 1; } |