[Wifidog] thread unsafe calls

Alexandre Carmel-Veilleux saruman at northernhacking.org
Fri Oct 22 23:35:18 EDT 2004

On Fri, Oct 22, 2004 at 11:00:59PM -0400, David Vincelli wrote:
> Good, hope it helps.

	It'd be interesting to know what happens when to thread "win"
the race condition and call gethostbyname() simulteanously (for the
same domain!). Which flavor of "undefined" can we expect? I would
expect a SEGV since the original thread can kiss it's copy of the
struct in_addr he->h_addr_list[0].

> You're right - I'm wrong. I misread the man page. OpenBSD man page 
> says it returns the size of the string -1 (\0) or the size that it
> would've been had it had enough space to allocate it. Then it goes 
> on to say that it returns -1 in case of error. It's a slightl 
> ambiguous, check the man page on the project's web site if you want.
> After re-reading the related blurb, I think it means it should never
> return -1.

	Quick perusing of the OpenBSD 2.9 /usr/src/lib/stdio files relating
to snprintf lead me to believe that it's theoretically possible for
snprintf to return EOF. But I haven't seen a condition where this would
happen that doesn't involve fprintf (they share the same code, but behave
quite differently through it.)

	File operations, obviously, are much more error prone.


-------------- next part --------------
Wifidog mailing list
Wifidog at isf.waglo.com

More information about the Wifidog mailing list