gethostbyname() feature.

Jakob Eriksson jakob at vmlinux.org
Sun Aug 31 09:09:19 CDT 2003


Maybe you could write a regression test for this function?


Rein Klazes wrote:

>hi,
>
>In the newsgroup someone reported a crash in gethostbyname() when the
>application called it with a null parameter.
>
>msdn says about this:
>
>| If null is provided in the name parameter, the returned string is
>| the same as the string returned by a successful gethostname
>| function call.
>
>gethostbyname does not return a string, but I think this it what they
>meant to say.
>I have tested gethostbyname under Win2K to do this.
>
>Changelog:
>	dlls/winsock	: socket.c async.c
>	_ws_gethostbyname() and WSAAsyncGetHostByName() when called with
>	a null name, should use the name returned by gethostname().
>
>Rein.
>  
>
>------------------------------------------------------------------------
>
>--- wine/dlls/winsock/socket.c	2003-08-31 10:00:10.000000000 +0200
>+++ mywine/dlls/winsock/socket.c	2003-08-31 09:59:16.000000000 +0200
>@@ -2903,6 +2903,16 @@
>     int ebufsize=1024;
>     struct hostent hostentry;
>     int locerr = ENOBUFS;
>+#endif
>+    char buf[100];
>+    if( !name) {
>+        name = buf;
>+        if( gethostname( buf, 100) == -1) {
>+            SetLastError( WSAENOBUFS); /* appropriate ? */
>+            return retval;
>+        }
>+    }
>+#ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
>     host = NULL;
>     extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
>     while(extrabuf) {
>--- wine/dlls/winsock/async.c	2003-08-31 10:00:10.000000000 +0200
>+++ mywine/dlls/winsock/async.c	2003-08-31 09:47:31.000000000 +0200
>@@ -402,6 +402,16 @@
>                         int ebufsize=1024;
>                         struct hostent hostentry;
>                         int locerr = ENOBUFS;
>+#endif
>+                        char buf[100];
>+                        if( !(aq->host_name)) {
>+                            aq->host_name = buf;
>+                            if( gethostname( buf, 100) == -1) {
>+                                fail = WSAENOBUFS; /* appropriate ? */
>+                                break;
>+                            }
>+                        }
>+#ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
>                         he = NULL;
>                         extrabuf=HeapAlloc(GetProcessHeap(),0,ebufsize) ;
>                         while(extrabuf) {
>  
>





More information about the wine-devel mailing list