X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/19693bdc06cca834589aae52fdd4b8475f4aec3a..87a513aa1d0f6eccd85b46d06cd13499d048f8c9:/client/nonce2key/nonce2key.c diff --git a/client/nonce2key/nonce2key.c b/client/nonce2key/nonce2key.c index 727f241d..638469a4 100644 --- a/client/nonce2key/nonce2key.c +++ b/client/nonce2key/nonce2key.c @@ -147,9 +147,11 @@ int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, ui printf("key_count: %d\n", key_count); if ( key_count == 0 ){ free(state); + state = NULL; return 0; } + uint8_t retval = 1; // Validate all key candidates with testing each of them with mfCheckKeys uint8_t keyBlock[6] = {0,0,0,0,0,0}; uint64_t key64; @@ -159,13 +161,17 @@ int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, ui key64 = 0; if (!mfCheckKeys(blockno, keytype, false, 1, keyBlock, &key64)) { *key = key64; - free(last_keylist); - last_keylist = NULL; - free(state); - return 0; + retval = 0; + goto out; } - } - return 1; + } + +out: + free(last_keylist); + last_keylist = NULL; + free(state); + state = NULL; + return retval; } // 32 bit recover key from 2 nonces