mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
g10: Minor clean up for export.c.
* g10/export.c (export_ssh_key): Check IDENTIFIER for error. Release base64 thing on error of get_membuf. -- Compiler (older) may misunderstand the variable IDENTIFIER is not initialized, while good one can do better analysys on the value for ERR (and thus, IDENTIFIER). On the error of get_membuf, still, b64enc_finish should be called, even if it lost the ERR value. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
c3cc9551dc
commit
0521882958
35
g10/export.c
35
g10/export.c
@ -2125,7 +2125,7 @@ export_ssh_key (ctrl_t ctrl, const char *userid)
|
|||||||
u32 curtime = make_timestamp ();
|
u32 curtime = make_timestamp ();
|
||||||
kbnode_t latest_key, node;
|
kbnode_t latest_key, node;
|
||||||
PKT_public_key *pk;
|
PKT_public_key *pk;
|
||||||
const char *identifier;
|
const char *identifier = NULL;
|
||||||
membuf_t mb;
|
membuf_t mb;
|
||||||
estream_t fp = NULL;
|
estream_t fp = NULL;
|
||||||
struct b64state b64_state;
|
struct b64state b64_state;
|
||||||
@ -2321,8 +2321,6 @@ export_ssh_key (ctrl_t ctrl, const char *userid)
|
|||||||
identifier = "ecdsa-sha2-nistp384";
|
identifier = "ecdsa-sha2-nistp384";
|
||||||
else if (!strcmp (curve, "nistp521"))
|
else if (!strcmp (curve, "nistp521"))
|
||||||
identifier = "ecdsa-sha2-nistp521";
|
identifier = "ecdsa-sha2-nistp521";
|
||||||
else
|
|
||||||
identifier = NULL;
|
|
||||||
|
|
||||||
if (!identifier)
|
if (!identifier)
|
||||||
err = gpg_error (GPG_ERR_UNKNOWN_CURVE);
|
err = gpg_error (GPG_ERR_UNKNOWN_CURVE);
|
||||||
@ -2353,7 +2351,7 @@ export_ssh_key (ctrl_t ctrl, const char *userid)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (!identifier)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
if (opt.outfile && *opt.outfile && strcmp (opt.outfile, "-"))
|
if (opt.outfile && *opt.outfile && strcmp (opt.outfile, "-"))
|
||||||
@ -2369,22 +2367,21 @@ export_ssh_key (ctrl_t ctrl, const char *userid)
|
|||||||
|
|
||||||
es_fprintf (fp, "%s ", identifier);
|
es_fprintf (fp, "%s ", identifier);
|
||||||
err = b64enc_start_es (&b64_state, fp, "");
|
err = b64enc_start_es (&b64_state, fp, "");
|
||||||
if (err)
|
if (!err)
|
||||||
goto leave;
|
{
|
||||||
{
|
void *blob;
|
||||||
void *blob;
|
size_t bloblen;
|
||||||
size_t bloblen;
|
|
||||||
|
|
||||||
blob = get_membuf (&mb, &bloblen);
|
blob = get_membuf (&mb, &bloblen);
|
||||||
if (!blob)
|
if (blob)
|
||||||
err = gpg_error_from_syserror ();
|
{
|
||||||
else
|
err = b64enc_write (&b64_state, blob, bloblen);
|
||||||
err = b64enc_write (&b64_state, blob, bloblen);
|
xfree (blob);
|
||||||
xfree (blob);
|
if (err)
|
||||||
if (err)
|
goto leave;
|
||||||
goto leave;
|
}
|
||||||
}
|
err = b64enc_finish (&b64_state);
|
||||||
err = b64enc_finish (&b64_state);
|
}
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
es_fprintf (fp, " openpgp:0x%08lX\n", (ulong)keyid_from_pk (pk, NULL));
|
es_fprintf (fp, " openpgp:0x%08lX\n", (ulong)keyid_from_pk (pk, NULL));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user