freeradius-client thread safety & memleaks patch

Alex Massover alex at
Sun Jul 25 11:29:50 CEST 2010


I want to sync changes I did to CVS. No new functionality only fixes for thread-safety and fixing memory leaks.
I use this code with static (shared among threads) rc_handle and experience no segfaults and no memory leaks :)

Some parts of this patch we posted before, but this one combines them all and is prepared against current CVS.


	- adding rad_hostent (will be used by ip_util.c)
	- changing functions signatures due to changes in ip_utils.c

	- using localtime_r() instead of non-reentrant localtime()
	- fixing minor memory leak posted by somebody else (not me) to this mail list, but not applied yet
	- inet_ntoa() is not reentrant, using inet_ntop() instead
	- gmtime_r() instead of gmtime()

	- rc_get_id() is now simple, fast and reentrant.

	- getservbyname_r() instead of getservbyname()
	- using rad_hostent in rc_gethostby*
	- fixing minor memleak - serv->secret[j] is not freed

	- using rad_hostent instead of thread-local buffer. Thread local storage is tricky and might leak in thread per request scenario
	- implementation of rc_ip_hostname() is copied from freeradius server. (something is wrong with current one)
	- using getservbyname_r() instead of getservbyname()

	- using new rc_ip_hostname()
	- using rand_r() instead of rand()

Best Regards,
Alex Massover
Jajah Inc.


This mail was sent via Mail-SeCure System.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: thread_safety.patch
Type: text/x-patch
Size: 13568 bytes
Desc: thread_safety.patch
URL: <>

More information about the Freeradius-Devel mailing list