From 1a084272fd5c603f318d2c4dc0c70b2de0606f04 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sun, 5 Jan 2014 09:44:47 -0800 Subject: [PATCH] Fix issue with looking up keys by fingerprint via HKP interface The index variable for the current parameter was being reused to parse the fingerprint, resulting in attempting to free an unallocated piece of memory and crashing. Use a different loop variable instead. --- lookup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lookup.c b/lookup.c index 9815cbb..12eb5a2 100644 --- a/lookup.c +++ b/lookup.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) { char **params = NULL; int op = OP_UNKNOWN; - int i; + int i, j; int indx = 0; bool dispfp = false; bool skshash = false; @@ -148,11 +148,11 @@ int main(int argc, char *argv[]) if (search != NULL && strlen(search) == 42 && search[0] == '0' && search[1] == 'x') { fingerprint.length = MAX_FINGERPRINT_LEN; - for (i = 0; i < MAX_FINGERPRINT_LEN; i++) { - fingerprint.fp[i] = (hex2bin( - search[2 + i * 2]) + for (j = 0; j < MAX_FINGERPRINT_LEN; j++) { + fingerprint.fp[j] = (hex2bin( + search[2 + j * 2]) << 4) + - hex2bin(search[3 + i * 2]); + hex2bin(search[3 + j * 2]); } isfp = true; } else if (search != NULL) { -- 2.39.2