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/Test_overflow.c | |
parent | e9e074f518658c46dcc45c9305c7ff4f8eade302 (diff) | |
download | libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.tar.gz libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.tar.bz2 libtasn1-4b1805a021aa9abe74ba775aaaff84fc21ea07e9.zip |
Add self-check.
Diffstat (limited to 'tests/Test_overflow.c')
-rw-r--r-- | tests/Test_overflow.c | 47 |
1 files changed, 47 insertions, 0 deletions
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; +} |