diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-12-26 13:15:25 -0500 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-01-02 10:17:34 +0100 |
commit | a1918b8f0e18c2f5104ad8e0cc00e56ca6a695d5 (patch) | |
tree | 22ad1ac539d9d4dba6da4b11f3fde987efe8e790 /tests | |
parent | 9789980c8f1d14aa6bfdeb87183dc37e91f7fef7 (diff) | |
download | gnutls-a1918b8f0e18c2f5104ad8e0cc00e56ca6a695d5.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.am | 1 | ||||
-rw-r--r-- | tests/cert-tests/data/truncated.pub | 1 | ||||
-rwxr-xr-x | tests/cert-tests/openpgp-cert-parser | 41 |
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} |