diff options
author | Werner Koch <[email protected]> | 2018-10-18 15:36:30 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-10-18 15:37:57 +0000 |
commit | fbac11b19d97730494dc9dad3b7f71453ef15581 (patch) | |
tree | ed3bbd8060989a0a70dfef6e4ae5c1d4acf30b55 /src/genkey.c | |
parent | core: Return an error if NULL is provided for genkey's parms. (diff) | |
download | gpgme-fbac11b19d97730494dc9dad3b7f71453ef15581.tar.gz gpgme-fbac11b19d97730494dc9dad3b7f71453ef15581.zip |
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 <[email protected]>
Diffstat (limited to 'src/genkey.c')
-rw-r--r-- | src/genkey.c | 8 |
1 files 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, "</GnupgKeyParms>"); + 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, |