diff options
author | Simon Josefsson <simon@josefsson.org> | 2012-03-13 23:47:28 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2012-03-13 23:47:28 +0100 |
commit | 4b1805a021aa9abe74ba775aaaff84fc21ea07e9 (patch) | |
tree | ef0d8c63b2060bb280716561fa044c3b2e3063bb /tests | |
parent | e9e074f518658c46dcc45c9305c7ff4f8eade302 (diff) | |
download | libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.tar.gz libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.tar.bz2 libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.zip |
Add self-check.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/Test_overflow.c | 47 |
2 files changed, 49 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9abc66d..61c8737 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,10 +34,10 @@ dist_check_SCRIPTS += threadsafety MOSTLYCLEANFILES = Test_parser_ERROR.asn check_PROGRAMS = Test_parser Test_tree Test_encoding Test_indefinite \ - Test_errors Test_simple + Test_errors Test_simple Test_overflow TESTS = Test_parser Test_tree Test_encoding Test_indefinite \ - Test_errors Test_simple crlf threadsafety + Test_errors Test_simple Test_overflow crlf threadsafety TESTS_ENVIRONMENT = \ ASN1PARSER=$(srcdir)/Test_parser.asn \ diff --git a/tests/Test_overflow.c b/tests/Test_overflow.c new file mode 100644 index 0000000..383f723 --- /dev/null +++ b/tests/Test_overflow.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Free Software Foundation, Inc. + * + * This file is part of LIBTASN1. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* Written by Simon Josefsson */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "libtasn1.h" + +int +main (void) +{ + unsigned char der[] = "\x84\x7F\xFF\xFF\xFF"; + long l; + int len; + + l = asn1_get_length_der (der, sizeof der, &len); + + if (l == -3L) + puts ("asn1_get_length_der rejected overflow OK"); + else + { + printf ("asn1_get_length_der overflow (l %lX len %X)\n", l, len); + return 1; + } + + return 0; +} |