From: Jonathan McDowell Date: Sun, 5 Jan 2014 17:44:47 +0000 (-0800) Subject: Fix issue with looking up keys by fingerprint via HKP interface X-Git-Tag: onak-0.4.3~18 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=1a084272fd5c603f318d2c4dc0c70b2de0606f04;p=onak.git 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. --- 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) {