summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2016-12-26 13:15:25 -0500
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-12-28 14:26:47 +0100
commit45991a484f5266a0bf42fddd01cd467ea23f5143 (patch)
tree2ef90b81dcf072579ac1f42630df1382aaef490e /tests
parent5fdfff4b269b5680d4c9132824a0e6bf7eb048db (diff)
downloadgnutls-45991a484f5266a0bf42fddd01cd467ea23f5143.tar.gz
Do not infinite loop if an EOF occurs while skipping a PGP packet
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/cert-tests/Makefile.am1
-rw-r--r--tests/cert-tests/data/truncated.pub1
-rwxr-xr-xtests/cert-tests/openpgp-cert-parser41
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/cert-tests/Makefile.am b/tests/cert-tests/Makefile.am
index 8d4923ad4f..e2499c9416 100644
--- a/tests/cert-tests/Makefile.am
+++ b/tests/cert-tests/Makefile.am
@@ -81,6 +81,7 @@ if ENABLE_OPENPGP
# The selftest is disabled until we can make it work under Wine and
# under Debian buildds (problem with 127.0.0.2?).
dist_check_SCRIPTS += openpgp-selfsigs
+dist_check_SCRIPTS += openpgp-cert-parser
if !WINDOWS
dist_check_SCRIPTS += openpgp-certs
endif
diff --git a/tests/cert-tests/data/truncated.pub b/tests/cert-tests/data/truncated.pub
new file mode 100644
index 0000000000..29e181ebb8
--- /dev/null
+++ b/tests/cert-tests/data/truncated.pub
@@ -0,0 +1 @@
+ÿ
diff --git a/tests/cert-tests/openpgp-cert-parser b/tests/cert-tests/openpgp-cert-parser
new file mode 100755
index 0000000000..9545fa0c6c
--- /dev/null
+++ b/tests/cert-tests/openpgp-cert-parser
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
+#
+# Author: Nikos Mavrogiannopoulos
+#
+# This file is part of GnuTLS.
+#
+# GnuTLS 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.
+#
+# GnuTLS 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 GnuTLS; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+set -e
+
+srcdir="${srcdir:-.}"
+CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}"
+
+unset RETCODE || true
+
+fail() {
+ echo "Failure: $1" >&2
+ RETCODE=${RETCODE:-${2:-1}}
+}
+
+echo "Checking OpenPGP certificate parsing"
+
+("${CERTTOOL}" --inraw --pgp-certificate-info --infile "${srcdir}/data/truncated.pub" 2>&1 \
+ | grep "^import error: Error in parsing" > /dev/null) || \
+ fail "Parsing should have errored"
+
+exit ${RETCODE:-0}