[PATCH gpg] gpg: Avoid assumption on fingerprint size.

Damien Goutte-Gattat dgouttegattat at incenp.org
Tue Feb 20 16:43:50 CET 2018


* g10/getkey.c (get_user_id_byfpr): Use the real size of the
fingerprint instead of MAX_FINGERPRINT_LEN.
--

MAX_FINGERPRINT_LEN was recently changed from 20 to 32, but the
get_user_id_byfpr was using this symbol as the actual size of the
fingerprint, thus confusing the get_pubkey_byfprint function which
does not expect a 32-bytes fingerprint.

GnuPG-bug-id: 3801
Signed-off-by: Damien Goutte-Gattat <dgouttegattat at incenp.org>
---
 g10/getkey.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/g10/getkey.c b/g10/getkey.c
index a838c3c61..0ab49f849 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -4243,6 +4243,9 @@ get_user_id_byfpr (ctrl_t ctrl, const byte *fpr, size_t *rn)
   user_id_db_t r;
   char *p;
   int pass = 0;
+  size_t fpr_len;
+
+  fpr_len = strlen (fpr);
 
   /* Try it two times; second pass reads from the database.  */
   do
@@ -4266,7 +4269,7 @@ get_user_id_byfpr (ctrl_t ctrl, const byte *fpr, size_t *rn)
 	}
     }
   while (++pass < 2
-	 && !get_pubkey_byfprint (ctrl, NULL, NULL, fpr, MAX_FINGERPRINT_LEN));
+	 && !get_pubkey_byfprint (ctrl, NULL, NULL, fpr, fpr_len));
   p = xstrdup (user_id_not_found_utf8 ());
   *rn = strlen (p);
   return p;
-- 
2.14.1




More information about the Gnupg-devel mailing list