RE: Possible race condition in gwlib/protected.c

"Oded Arbel" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>

> -----Original Message-----
> From: Kieran [mailto:[email protected]]
> Sent: Wednesday, August 21, 2002 6:02 AM
> To: [email protected]
> Subject: Possible race condition in gwlib/protected.c
> 
> 
> Hi,
> 
> I'm feeling my way into the kannel source, and I think I've identified
> a race condition in the gw_gethostbyname() function in 
> gwlib/protected.c
> In particular, the gethostbyname function call returns some 
> static data.
> 
> I've rolled patch to fix this, noting that:
> 1. The only callers in the of gw_gethostbyname in tree 
> currently are in
>    gwlib/socket.c
> 2. Those callers only use the hostent.h_name and 
> hostent.h_addr_list[0]
>    fields in the struct hostent.
> 3. I've been careful to free the memory allocated as close to the call
>    to gw_gethostbyname() as possible.
> 
> The patch thus copies mallocs space for these fields, and copies the
> relevant data, and then frees it.

Nice catch. I like the patch too, and will vote for it if you stop using gw_native_malloc() and call the macro wrapper instead. some of us are using checking or even slow malloc from time to time, and its such a waste having a memory allocation checker and then opting out of using it.

--
Oded Arbel
m-Wise mobile solutions
[email protected]

+972-9-9581711 (116)
+972-67-340014

::..
"I'm all for computer dating, but I wouldn't want one to marry my sister."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.