Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-thread-safe use of inet_ntoa #297

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments
Open

Non-thread-safe use of inet_ntoa #297

GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Mongoose seems to call inet_ntoa from various places in worker threads. 
inet_ntoa is documented in man pages as returning a pointer to a 
statically-allocated buffer, so it may corrupt the buffer if two threads 
(either two Mongoose threads, or Mongoose plus an application it's embedded in) 
run it simultaneously.

(http://www.apsis.ch/pound/pound_list/archive/2006/2006-07/1151745756000 
reports the kinds of errors this can lead to.)

In practice, at least recent versions of glibc use a per-thread buffer, and 
MSDN says the buffer is valid until the next WinSock call on the same thread, 
so they'll be safe, but other implementations might vary.

inet_ntop with a caller-allocated buffer looks like the right way to fix this.

Original issue reported on code.google.com by [email protected] on 23 Nov 2011 at 11:14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant