aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyid.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-12-18 15:38:02 +0000
committerWerner Koch <[email protected]>2017-12-18 15:42:59 +0000
commitc817e750283278e7e8317c1b47981e71ddcc9dbf (patch)
tree0865a55b588243ac2883c483959ec483c4c2e9ae /g10/keyid.c
parentpo: Update Japanese translation. (diff)
parentgpgconf: Show --compliance in expert mode. (diff)
downloadgnupg-c817e750283278e7e8317c1b47981e71ddcc9dbf.tar.gz
gnupg-c817e750283278e7e8317c1b47981e71ddcc9dbf.zip
Merge branch 'STABLE-BRANCH-2-2' into master
-- Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keyid.c')
-rw-r--r--g10/keyid.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 460c02982..a9034ee46 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -790,12 +790,12 @@ fingerprint_from_pk (PKT_public_key *pk, byte *array, size_t *ret_len)
/* Return an allocated buffer with the fingerprint of PK formatted as
- a plain hexstring. If BUFFER is NULL the result is a malloc'd
- string. If BUFFER is not NULL the result will be copied into this
- buffer. In the latter case BUFLEN describes the length of the
- buffer; if this is too short the function terminates the process.
- Returns a malloc'ed string or BUFFER. A suitable length for BUFFER
- is (2*MAX_FINGERPRINT_LEN + 1). */
+ * a plain hexstring. If BUFFER is NULL the result is a malloc'd
+ * string. If BUFFER is not NULL the result will be copied into this
+ * buffer. In the latter case BUFLEN describes the length of the
+ * buffer; if this is too short the function terminates the process.
+ * Returns a malloc'ed string or BUFFER. A suitable length for BUFFER
+ * is (2*MAX_FINGERPRINT_LEN + 1). */
char *
hexfingerprint (PKT_public_key *pk, char *buffer, size_t buflen)
{
@@ -804,7 +804,11 @@ hexfingerprint (PKT_public_key *pk, char *buffer, size_t buflen)
fingerprint_from_pk (pk, fpr, &len);
if (!buffer)
- buffer = xmalloc (2 * len + 1);
+ {
+ buffer = xtrymalloc (2 * len + 1);
+ if (!buffer)
+ return NULL;
+ }
else if (buflen < 2*len+1)
log_fatal ("%s: buffer too short (%zu)\n", __func__, buflen);
bin2hex (fpr, len, buffer);