core: Return an error if NULL is provided for genkey's parms.

* src/debug.c (_gpgme_debug_buffer): Bail out of BUF is NULL.
* src/genkey.c (gpgme_op_genkey): Do no deref a NULL in
TRACE_LOGBUF.
(gpgme_op_genkey_start): Ditto. Return an error if PARMS is NULL.
--

This robustness patch should solve one part of
GnuPG-bug-id: 4192
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-10-18 16:50:18 +02:00
parent 9de1c96ac3
commit 174af15725
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 6 additions and 3 deletions

View File

@ -379,6 +379,9 @@ _gpgme_debug_buffer (int lvl, const char *const fmt,
if (!_gpgme_debug_trace ())
return;
if (!buffer)
return;
while (idx < len)
{
char str[51];

View File

@ -283,9 +283,9 @@ gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey_start", ctx,
"pubkey=%p, seckey=%p", pubkey, seckey);
TRACE_LOGBUF (parms, strlen (parms));
TRACE_LOGBUF (parms, parms? strlen (parms):0);
if (!ctx)
if (!ctx || parms)
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
err = genkey_start (ctx, 0, parms, pubkey, seckey);
@ -304,7 +304,7 @@ gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey,
TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey", ctx,
"pubkey=%p, seckey=%p", pubkey, seckey);
TRACE_LOGBUF (parms, strlen (parms));
TRACE_LOGBUF (parms, parms? strlen (parms):0);
if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));