summaryrefslogtreecommitdiff
path: root/tests/Test_overflow.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Test_overflow.c')
-rw-r--r--tests/Test_overflow.c47
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;
+}