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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-10-18 17:36:30 +02:00
parent 174af15725
commit fbac11b19d
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -223,9 +223,13 @@ get_key_parameter (const char *parms, gpgme_data_t *key_parameter)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
endtag = strstr (content, "</GnupgKeyParms>"); endtag = strstr (content, "</GnupgKeyParms>");
if (!endtag)
endtag = content + strlen (content);
/* FIXME: Check that there are no control statements inside. */ /* FIXME: Check that there are no control statements inside. */
while (content[0] == '\n' while (content < endtag
|| (content[0] == '\r' && content[1] == '\n')) && (content[0] == '\n'
|| (content[0] == '\r' && content[1] == '\n')))
content++; content++;
return gpgme_data_new_from_mem (key_parameter, content, return gpgme_data_new_from_mem (key_parameter, content,