1 byte leak ?

Alan DeKok aland at deployingradius.com
Sat Dec 8 23:25:41 CET 2007

blue_11j at yahoo.co.jp wrote:
> I found memory leak(?) of 1 byte when PEAP authentication, by valgrind.

  Can you provide a test case, hopefully with wpa_supplicant as the client?

> I tried fllowing patch for rlm_eap.
> it look like work well.
> is it corret way?

  I'm not sure.  The "type.data" field *is* malloc'd.  It is NOT free'd
in eap_packet_free().  However, it *is* free'd in eap_wireformat().

  The only time I can see there being a memory leak is when the EAP
packet is allocated, *but* it is never encoded into the wire-format.

  If you go to the rlm_eap directory, you can do:

$  grep -r alloc . | grep type.data | grep c:

  That will give you around 10 locations where type.data = malloc(...).
If this is really a memory leak, then *all* of those locations will
likely have to be fixed.

  The following change inside of eap_packet_free() *should* catch all
corner cases.

  Alan DeKok.

   	if (eap_packet->type.data) {
		 *	There IS a packet, AND the data portion points
		 *	to the EAP data: do nothing.  Otherwise, free it.
		if (!(eap_packet->packet &&
		      (eap_packet->type.data == (eap_packet->packet + 5)))) {
		eap_packet->type.data = NULL;

More information about the Freeradius-Users mailing list