mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
sm: Fix possible NULL deref in error messages of --gen-key.
* sm/certreqgen.c: Protect printing the liniernur in case of !R. -- GnuPG-bug-id: 4895 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
0b583a555e
commit
9c5c7c6f60
@ -199,7 +199,7 @@ parse_parameter_usage (struct para_data_s *para, enum para_name key)
|
||||
use |= GCRY_PK_USAGE_CERT;
|
||||
else
|
||||
{
|
||||
log_error ("line %d: invalid usage list\n", r->lnr);
|
||||
log_error ("line %d: invalid usage list\n", r?r->lnr:0);
|
||||
return -1; /* error */
|
||||
}
|
||||
}
|
||||
@ -465,7 +465,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
{
|
||||
r = get_parameter (para, pKEYTYPE, 0);
|
||||
if (r)
|
||||
log_error (_("line %d: invalid algorithm\n"), r->lnr);
|
||||
log_error (_("line %d: invalid algorithm\n"), r?r->lnr:0);
|
||||
else
|
||||
log_error ("No Key-Type specified\n");
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
@ -482,7 +482,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
/* The BSI specs dated 2002-11-25 don't allow lengths below 1024. */
|
||||
r = get_parameter (para, pKEYLENGTH, 0);
|
||||
log_error (_("line %d: invalid key length %u (valid are %d to %d)\n"),
|
||||
r->lnr, nbits, 1024, 4096);
|
||||
r?r->lnr:0, nbits, 1024, 4096);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -499,7 +499,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (!(s=get_parameter_value (para, pNAMEDN, 0)))
|
||||
{
|
||||
r = get_parameter (para, pNAMEDN, 0);
|
||||
log_error (_("line %d: no subject name given\n"), r->lnr);
|
||||
log_error (_("line %d: no subject name given\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -509,10 +509,10 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
r = get_parameter (para, pNAMEDN, 0);
|
||||
if (gpg_err_code (err) == GPG_ERR_UNKNOWN_NAME)
|
||||
log_error (_("line %d: invalid subject name label '%.*s'\n"),
|
||||
r->lnr, (int)errlen, s+erroff);
|
||||
r?r->lnr:0, (int)errlen, s+erroff);
|
||||
else
|
||||
log_error (_("line %d: invalid subject name '%s' at pos %d\n"),
|
||||
r->lnr, s, (int)erroff);
|
||||
r?r->lnr:0, s, (int)erroff);
|
||||
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
@ -528,7 +528,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
|| strstr(s, ".."))
|
||||
{
|
||||
r = get_parameter (para, pNAMEEMAIL, seq);
|
||||
log_error (_("line %d: not a valid email address\n"), r->lnr);
|
||||
log_error (_("line %d: not a valid email address\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -547,7 +547,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (*s)
|
||||
{
|
||||
r = get_parameter (para, pSERIAL, 0);
|
||||
log_error (_("line %d: invalid serial number\n"), r->lnr);
|
||||
log_error (_("line %d: invalid serial number\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -564,10 +564,10 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
r = get_parameter (para, pISSUERDN, 0);
|
||||
if (gpg_err_code (err) == GPG_ERR_UNKNOWN_NAME)
|
||||
log_error (_("line %d: invalid issuer name label '%.*s'\n"),
|
||||
r->lnr, (int)errlen, string+erroff);
|
||||
r?r->lnr:0, (int)errlen, string+erroff);
|
||||
else
|
||||
log_error (_("line %d: invalid issuer name '%s' at pos %d\n"),
|
||||
r->lnr, string, (int)erroff);
|
||||
r?r->lnr:0, string, (int)erroff);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -578,7 +578,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (string && !string2isotime (NULL, string))
|
||||
{
|
||||
r = get_parameter (para, pNOTBEFORE, 0);
|
||||
log_error (_("line %d: invalid date given\n"), r->lnr);
|
||||
log_error (_("line %d: invalid date given\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -589,7 +589,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (string && !string2isotime (NULL, string))
|
||||
{
|
||||
r = get_parameter (para, pNOTAFTER, 0);
|
||||
log_error (_("line %d: invalid date given\n"), r->lnr);
|
||||
log_error (_("line %d: invalid date given\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -603,7 +603,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
{
|
||||
r = get_parameter (para, pKEYTYPE, 0);
|
||||
log_error (_("line %d: error getting signing key by keygrip '%s'"
|
||||
": %s\n"), r->lnr, s, gpg_strerror (rc));
|
||||
": %s\n"), r?r->lnr:0, s, gpg_strerror (rc));
|
||||
xfree (cardkeyid);
|
||||
return rc;
|
||||
}
|
||||
@ -621,7 +621,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
|| mdalgo == GCRY_MD_SHA512)))
|
||||
{
|
||||
r = get_parameter (para, pHASHALGO, 0);
|
||||
log_error (_("line %d: invalid hash algorithm given\n"), r->lnr);
|
||||
log_error (_("line %d: invalid hash algorithm given\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -636,7 +636,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (*s || (i&1))
|
||||
{
|
||||
r = get_parameter (para, pAUTHKEYID, 0);
|
||||
log_error (_("line %d: invalid authority-key-id\n"), r->lnr);
|
||||
log_error (_("line %d: invalid authority-key-id\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -651,7 +651,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (*s || (i&1))
|
||||
{
|
||||
r = get_parameter (para, pSUBJKEYID, 0);
|
||||
log_error (_("line %d: invalid subject-key-id\n"), r->lnr);
|
||||
log_error (_("line %d: invalid subject-key-id\n"), r?r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -689,7 +689,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
if (!okay)
|
||||
{
|
||||
r = get_parameter (para, pEXTENSION, seq);
|
||||
log_error (_("line %d: invalid extension syntax\n"), r->lnr);
|
||||
log_error (_("line %d: invalid extension syntax\n"), r? r->lnr:0);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
}
|
||||
@ -703,7 +703,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
{
|
||||
r = get_parameter (para, pKEYTYPE, 0);
|
||||
log_error (_("line %d: error reading key '%s' from card: %s\n"),
|
||||
r->lnr, cardkeyid, gpg_strerror (rc));
|
||||
r?r->lnr:0, cardkeyid, gpg_strerror (rc));
|
||||
xfree (sigkey);
|
||||
xfree (cardkeyid);
|
||||
return rc;
|
||||
@ -750,7 +750,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
else
|
||||
{
|
||||
r = get_parameter (para, pKEYTYPE, 0);
|
||||
log_error (_("line %d: invalid algorithm\n"), r->lnr);
|
||||
log_error (_("line %d: invalid algorithm\n"), r?r->lnr:0);
|
||||
xfree (sigkey);
|
||||
xfree (cardkeyid);
|
||||
return gpg_error (GPG_ERR_INV_PARAMETER);
|
||||
@ -760,7 +760,7 @@ proc_parameters (ctrl_t ctrl, struct para_data_s *para,
|
||||
{
|
||||
r = get_parameter (para, pKEYTYPE, 0);
|
||||
log_error (_("line %d: key generation failed: %s <%s>\n"),
|
||||
r->lnr, gpg_strerror (rc), gpg_strsource (rc));
|
||||
r?r->lnr:0, gpg_strerror (rc), gpg_strsource (rc));
|
||||
xfree (sigkey);
|
||||
xfree (cardkeyid);
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user