Re: Wine: gethostbyname implementation in WS2_32 is buggy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "rzroli" ==   <rzoli@yahoo.com> writes:

    rzoli> Hi, I am not confident how this patch-submission bussiness
    rzoli> works, so I will just quickly describe what's wrong and how to
    rzoli> fix it.

    rzoli> The current implementation of gethostbyname in WS2_32 (located
    rzoli> in winsock/socket.c) doesn't handle a null string argument
    rzoli> correctly.

    rzoli> According to MS definition of gethostbyname, when it receives a
    rzoli> null argument, it should return the same result as if a call to
    rzoli> gethostname was made. Currently Wine doesn't do this: it simply
    rzoli> crashes.

    rzoli> Fix is simple: add something like: if (name == NULL) return
    rzoli> __ws_gethostbyname( "localhost", WS_DUP_LINEAR );

    rzoli> I hope this helps you out a bit.  Good luck with the project,
    rzoli> it's been very useful to me.

Do something like
cvs -d $CVSROOT diff -u wine/dlls/winsock/socket.c wine/dlls/winsock/tests/sock.c > winsock_patch

Write a Changelog:
    wine/dlls/winsock/socket.c: gethostbyname
    NULL as name is handled like gethostbyname
    (as spooted by  <rzoli@yahoo.com>)

and attach the patch
-- 
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/winsock/socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.126
diff -u -r1.126 socket.c
--- wine/dlls/winsock/socket.c	13 May 2003 04:43:44 -0000	1.126
+++ wine/dlls/winsock/socket.c	16 May 2003 19:38:15 -0000
@@ -2937,6 +2937,8 @@
 struct WS_hostent* WINAPI WS_gethostbyname(const char* name)
 {
     TRACE( "%s\n", debugstr_a(name) );
+    if (name == NULL)
+      return __ws_gethostbyname("localhost", WS_DUP_LINEAR );
     return __ws_gethostbyname( name, WS_DUP_LINEAR );
 }
 
Index: wine/dlls/winsock/tests/sock.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/tests/sock.c,v
retrieving revision 1.9
diff -u -r1.9 sock.c
--- wine/dlls/winsock/tests/sock.c	2 Apr 2003 01:38:42 -0000	1.9
+++ wine/dlls/winsock/tests/sock.c	16 May 2003 19:38:19 -0000
@@ -676,6 +676,14 @@
     }
 };
 
+void test_gethostbyname(void)
+{
+  struct hostent* ret;
+
+  ret = gethostbyname(NULL);
+  ok (ret !=0, "gethostbyname(NULL) failed");
+
+}
 /**************** Main program  ***************/
 
 START_TEST( sock )
@@ -689,6 +697,6 @@
         do_test (  &tests[i] );
         trace ( " **** TEST %d COMPLETE **** \n", i );
     }
-
+    test_gethostbyname();
     Exit();
 }


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux