Wine: gethostbyname implementation in WS2_32 is buggy
andi at rhlx01.fht-esslingen.de
Fri May 16 15:03:14 CDT 2003
On Fri, May 16, 2003 at 04:59:18PM +0100, wrote:
> I am not confident how this patch-submission bussiness
> works, so I will just quickly describe what's wrong
> and how to fix it.
> The current implementation of gethostbyname in WS2_32
> (located in winsock/socket.c) doesn't handle a null
> string argument correctly.
> According to MS definition of gethostbyname, when it
> receives a null argument, it should return the same
> result as if a call to gethostname was made. Currently
> Wine doesn't do this: it simply crashes.
> Fix is simple: add something like:
> if (name == NULL) return __ws_gethostbyname(
> "localhost", WS_DUP_LINEAR );
Is this the way it's supposed to be handled?
I interpreted this (in my original patch I sent very recently) as
--- dlls/winsock/socket.c 13 May 2003 04:43:44 -0000 1.126
+++ dlls/winsock/socket.c 16 May 2003 20:00:28 -0000
@@ -2893,6 +2893,17 @@
struct hostent hostentry;
int locerr = ENOBUFS;
+ char local_name;
+ /* name == NULL means use the local host name */
+ if (name == NULL)
+ if (WS_gethostname(local_name, sizeof(local_name)) != 0)
+ return NULL;
+ name = local_name;
host = NULL;
Which way is the right one? First? Second? Both? :)
Help prevent Information Technology Fascism! - before it's too late...
More information about the wine-devel