summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-01-08 20:51:59 +0100
committerWerner Koch <wk@gnupg.org>2009-01-08 20:51:59 +0100
commit901842d5221bcef539ec8d66109fbfaf3c8988ee (patch)
tree868d01b0e03f013efd89dc5e41f89e90a2d89c33 /sm
parentUpdate spanish translation. (diff)
downloadgnupg2-901842d5221bcef539ec8d66109fbfaf3c8988ee.tar.xz
gnupg2-901842d5221bcef539ec8d66109fbfaf3c8988ee.zip
Fix error detection
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog4
-rw-r--r--sm/fingerprint.c14
2 files changed, 12 insertions, 6 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index b47b3a45b..dae0a544c 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-08 Werner Koch <wk@g10code.com>
+
+ * fingerprint.c (gpgsm_get_keygrip_hexstring): Add error detection.
+
2008-12-10 Werner Koch <wk@g10code.com>
* gpgsm.c (our_cipher_test_algo): Use the GCRY constants as we now
diff --git a/sm/fingerprint.c b/sm/fingerprint.c
index 1c65512a6..6581688a8 100644
--- a/sm/fingerprint.c
+++ b/sm/fingerprint.c
@@ -152,9 +152,9 @@ gpgsm_get_short_fingerprint (ksba_cert_t cert)
/* Return the so called KEYGRIP which is the SHA-1 hash of the public
- key parameters expressed as an canoncial encoded S-Exp. array must
- be 20 bytes long. returns the array or a newly allocated one if the
- passed one was NULL */
+ key parameters expressed as an canoncial encoded S-Exp. ARRAY must
+ be 20 bytes long. Returns ARRAY or a newly allocated buffer if ARRAY was
+ given as NULL. May return NULL on error. */
unsigned char *
gpgsm_get_keygrip (ksba_cert_t cert, unsigned char *array)
{
@@ -204,9 +204,11 @@ gpgsm_get_keygrip_hexstring (ksba_cert_t cert)
unsigned char grip[20];
char *buf;
- gpgsm_get_keygrip (cert, grip);
- buf = xmalloc (20*2+1);
- bin2hex (grip, 20, buf);
+ if (!gpgsm_get_keygrip (cert, grip))
+ return NULL;
+ buf = xtrymalloc (20*2+1);
+ if (buf)
+ bin2hex (grip, 20, buf);
return buf;
}