summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-04 15:03:12 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-06 08:04:40 +0100
commit56ea2b67c231075fe79a4a55963658162061bbdd (patch)
treee583d04f6b06e4f9466c52b40b9df2670c6eb726
parent8c699a16ba73e527a269792bacb49676aee42028 (diff)
downloadgnutls-56ea2b67c231075fe79a4a55963658162061bbdd.tar.gz
tests: added test case with invalid openpgp cert
This triggers an out of memory error. Issue found using oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=337 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--tests/cert-tests/data/openpgp-invalid4.pub1
-rwxr-xr-xtests/cert-tests/openpgp-cert-parser43
2 files changed, 9 insertions, 35 deletions
diff --git a/tests/cert-tests/data/openpgp-invalid4.pub b/tests/cert-tests/data/openpgp-invalid4.pub
new file mode 100644
index 0000000000..5bd7dea14b
--- /dev/null
+++ b/tests/cert-tests/data/openpgp-invalid4.pub
@@ -0,0 +1 @@
+¶ \ No newline at end of file
diff --git a/tests/cert-tests/openpgp-cert-parser b/tests/cert-tests/openpgp-cert-parser
index 3d96848d45..d5c30f23fd 100755
--- a/tests/cert-tests/openpgp-cert-parser
+++ b/tests/cert-tests/openpgp-cert-parser
@@ -40,40 +40,13 @@ fail() {
echo "Checking OpenPGP certificate parsing"
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/truncated.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
-
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/attribute-leak-1.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
-
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/subpkt-leak.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
-
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/openpgp-invalid1.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
-
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/openpgp-invalid2.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
-
-${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/openpgp-invalid3.pub" 2>&1
-rc=$?
-if test $rc != 1;then
- fail "Parsing should have errored"
-fi
+for i in "truncated.pub" "attribute-leak-1.pub" "subpkt-leak.pub" "openpgp-invalid1.pub" \
+ "openpgp-invalid2.pub" "openpgp-invalid3.pub" "openpgp-invalid4.pub";do
+ ${VALGRIND} "${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/${i}"
+ rc=$?
+ if test $rc != 1;then
+ fail "$i: Parsing should have errored ($rc)"
+ fi
+done
exit ${RETCODE:-0}