From fbac11b19d97730494dc9dad3b7f71453ef15581 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 18 Oct 2018 17:36:30 +0200 Subject: [PATCH] core: Fix segv in genkey when no endtag is provided. * src/genkey.c (get_key_parameter): Provide a fallback ENDTAG. -- It would actually be more correct to return an error in this case but it is possible tha there are users who did not provide an endtag and out of luck they also didn't trigger a segv. GnuPG-bug-id: 4192 Signed-off-by: Werner Koch --- src/genkey.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/genkey.c b/src/genkey.c index 0108aab0..e00d0475 100644 --- a/src/genkey.c +++ b/src/genkey.c @@ -223,9 +223,13 @@ get_key_parameter (const char *parms, gpgme_data_t *key_parameter) return gpg_error (GPG_ERR_INV_VALUE); endtag = strstr (content, ""); + if (!endtag) + endtag = content + strlen (content); + /* FIXME: Check that there are no control statements inside. */ - while (content[0] == '\n' - || (content[0] == '\r' && content[1] == '\n')) + while (content < endtag + && (content[0] == '\n' + || (content[0] == '\r' && content[1] == '\n'))) content++; return gpgme_data_new_from_mem (key_parameter, content,