Memory leak bug fix discovered through the "altered HMAC test"

This commit fixes a memory leak caught with valgrind in the "altered HMAC
test":

 [+] fwknop functions (unique view):
-        9 : ???
-        4 : main
-        4 : pcap_capture
-        2 : incoming_spa
-        2 : fko_new_with_data
-        2 : fko_verify_hmac
+        7 : ???
+        2 : pcap_capture
+        2 : main
         1 : pcap_compile
-        1 : strdup
-        1 : fko_calculate_hmac
-        1 : add_salted_str

 [+] fwknop functions (with call line numbers):
-        9 : ??? (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
-        4 : main (fwknopd.c:299)
-        2 : fko_new_with_data (fko_funcs.c:220)
-        2 : pcap_capture (pcap_capture.c:226)
-        2 : incoming_spa (incoming_spa.c:378)
-        1 : add_salted_str (cipher_funcs.c:298)
-        1 : strdup (strdup.c:43)
-        1 : fko_verify_hmac (fko_hmac.c:78)
-        1 : fko_verify_hmac (fko_hmac.c:92)
-        1 : pcap_capture (pcap_capture.c:105)
+        7 : ??? (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
+        2 : main (fwknopd.c:299)
         1 : pcap_compile (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.1.1)
         1 : pcap_capture (pcap_capture.c:97)
-        1 : fko_calculate_hmac (fko_hmac.c:169)
+        1 : pcap_capture (pcap_capture.c:105)
This commit is contained in:
Michael Rash 2012-08-19 10:43:30 -04:00
parent 6199180c69
commit e80a6de5f7

View File

@ -206,24 +206,24 @@ fko_new_with_data(fko_ctx_t *r_ctx, const char *enc_msg,
*/
ctx->initval = FKO_CTX_INITIALIZED;
res = fko_set_spa_encryption_mode(ctx, encryption_mode);
ctx->initval = 0;
if(res != FKO_SUCCESS)
{
fko_destroy(ctx);
return res;
}
ctx->initval = 0;
/* Check HMAC if the access stanza had an HMAC key
*/
ctx->initval = FKO_CTX_INITIALIZED;
if(hmac_key_len > 0 && hmac_key != NULL)
res = fko_verify_hmac(ctx, hmac_key, hmac_key_len);
ctx->initval = 0;
if(res != FKO_SUCCESS)
{
fko_destroy(ctx);
return res;
}
ctx->initval = 0;
/* Consider it initialized here.
*/