Project

General

Profile

Bug #369

Potential memory leak in check_cookie function in receiver.c

Added by Piyush Patel about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Category:
libcharon
Target version:
Start date:
29.07.2013
Due date:
Estimated time:
Affected version:
5.0.4
Resolution:
Fixed

Description

Valgrind report memory leaks in check_cookie function in src/libcharon/network/receiver.c. I was trying to load test my gateway setup. I'm not sure the particular condition but valgrind reported memory leak. I applied the below fix and that seemed to fix the issue.

The code I applied the fix is for 5.0.4.

--- receiver.c.orig 2013-07-29 10:23:51.419625605 -0700
++ receiver.c 2013-07-29 09:52:40.922880698 -0700
@ -288,6 +288,7 @
packet->destroy(packet);
return FALSE;
}
packet->destroy(packet);
return TRUE;
}

Associated revisions

Revision a566c5f8 (diff)
Added by Tobias Brunner about 6 years ago

receiver: Avoid cloning packet data when verifying COOKIE payloads

Besides being more efficient this removes a memory leak that occurred
when a COOKIE payload was successfully verified.

Fixes #369.

History

#1 Updated by Piyush Patel about 6 years ago

Sorry the code diff got messed up:

--- receiver.c.orig    2013-07-29 10:23:51.419625605 -0700
+++ receiver.c    2013-07-29 09:52:40.922880698 -0700
@@ -288,6 +288,7 @@
         packet->destroy(packet);
         return FALSE;
     }
+    packet->destroy(packet);
     return TRUE;
 }

#2 Updated by Tobias Brunner about 6 years ago

  • Tracker changed from Issue to Bug
  • Category set to libcharon
  • Status changed from New to Closed
  • Assignee set to Tobias Brunner
  • Target version set to 5.1.0
  • Resolution set to Fixed

Thanks for the report. There was in fact a memory leak whenever a COOKIE payload was successfully verified.

I changed to code to use the more efficient get_packet_data method, thus, avoiding the cloned packet and preventing the memory leak.

Also available in: Atom PDF