[gethostbyname] Set appropriate error code

BiGgUn fbiggun at hotmail.com
Wed Sep 3 11:20:56 CDT 2003


Changelog:
  - Set appropriate error code for gethostbyname and WSAAsyncGetHostByName
  - Restore NULL name/aq->host_name to NULL at the end of each function respectively

Stephan

Index: async.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/async.c,v
retrieving revision 1.30
diff -u -u -r1.30 async.c
--- async.c 2 Sep 2003 18:12:20 -0000 1.30
+++ async.c 3 Sep 2003 16:02:53 -0000
@@ -407,7 +407,7 @@
                         if( !(aq->host_name)) {
                             aq->host_name = buf;
                             if( gethostname( buf, 100) == -1) {
-                                fail = WSAENOBUFS; /* appropriate ? */
+                                fail = (errno == EINVAL) ? WSAEFAULT : wsaErrno();
                                 break;
                             }
                         }
@@ -427,7 +427,7 @@
                         if (!he) fail = ((locerr < 0) ? wsaErrno() : wsaHerrno(locerr));
 #else
                         EnterCriticalSection( &csWSgetXXXbyYYY );
-   he = (aq->flags & AQ_NAME) ?
+       he = (aq->flags & AQ_NAME) ?
     gethostbyname(aq->host_name):
     gethostbyaddr(aq->host_addr,aq->host_len,aq->host_type);
                         if (!he) fail = ((h_errno < 0) ? wsaErrno() : wsaHerrno(h_errno));
@@ -444,6 +444,7 @@
 #else
                         LeaveCriticalSection( &csWSgetXXXbyYYY );
 #endif
+   if (aq->host_name==buf) aq->host_name = NULL;
   }
   break;
  case AQ_GETPROTO: {
Index: socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.135
diff -u -u -r1.135 socket.c
--- socket.c 2 Sep 2003 18:12:20 -0000 1.135
+++ socket.c 3 Sep 2003 16:02:54 -0000
@@ -2908,8 +2908,8 @@
     if( !name) {
         name = buf;
         if( gethostname( buf, 100) == -1) {
-            SetLastError( WSAENOBUFS); /* appropriate ? */
-            return retval;
+            SetLastError((errno == EINVAL) ? WSAEFAULT : wsaErrno());
+            return NULL;
         }
     }
 #ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
@@ -2938,6 +2938,7 @@
 #else
     LeaveCriticalSection( &csWSgetXXXbyYYY );
 #endif
+    if (name==buf) name=NULL;
     return retval;
 }




More information about the wine-patches mailing list