diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/Test_overflow.c | 47 |
3 files changed, 50 insertions, 2 deletions
@@ -4,6 +4,7 @@ GNU Libtasn1 NEWS -*- outline -*- - Cleanup license headers. - build: Update gnulib files. - Corrected DER decoding issue (reported by Matthew Hall). + Added self check to detect the problem, see tests/Test_overflow.c. * Noteworthy changes in release 2.11 (2011-11-25) [stable] - qa: Now builds without compiler warnings with Solaris CC. 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; +} |