From e08b66b7cb4bc3f7ad56d081f0357ec1d39aa4ec Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Wed, 4 Jan 2017 14:47:11 +0100 Subject: tests: added test case with invalid openpgp cert This triggers a memory error. Issue found using oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=346 Signed-off-by: Nikos Mavrogiannopoulos --- tests/cert-tests/Makefile.am | 2 +- tests/cert-tests/data/openpgp-invalid2.pub | Bin 0 -> 187 bytes tests/cert-tests/openpgp-cert-parser | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/cert-tests/data/openpgp-invalid2.pub diff --git a/tests/cert-tests/Makefile.am b/tests/cert-tests/Makefile.am index 2c14da68fd..51a4e5c63d 100644 --- a/tests/cert-tests/Makefile.am +++ b/tests/cert-tests/Makefile.am @@ -62,7 +62,7 @@ EXTRA_DIST = data/ca-no-pathlen.pem data/no-ca-or-pathlen.pem data/aki-cert.pem data/code-signing-ca.pem data/code-signing-cert.pem data/multi-value-dn.pem \ data/pkcs7-cat-ca.pem data/pkcs7-cat.p7 data/openssl.p7b data/openssl.p7b.out \ data/openssl-keyid.p7b data/openssl-keyid.p7b.out data/openssl.p12 \ - data/openpgp-invalid1.pub + data/openpgp-invalid1.pub data/openpgp-invalid2.pub dist_check_SCRIPTS = pathlen aki certtool invalid-sig email \ pkcs7 pkcs7-broken-sigs privkey-import name-constraints certtool-long-cn crl provable-privkey \ diff --git a/tests/cert-tests/data/openpgp-invalid2.pub b/tests/cert-tests/data/openpgp-invalid2.pub new file mode 100644 index 0000000000..93d9df5ce5 Binary files /dev/null and b/tests/cert-tests/data/openpgp-invalid2.pub differ diff --git a/tests/cert-tests/openpgp-cert-parser b/tests/cert-tests/openpgp-cert-parser index eb3cb1ac98..c38789441c 100755 --- a/tests/cert-tests/openpgp-cert-parser +++ b/tests/cert-tests/openpgp-cert-parser @@ -64,4 +64,10 @@ 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 + exit ${RETCODE:-0} -- cgit v1.2.1