A little defensive programming in winsock.

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

 



Good day!

I saw this with a test winsock program Anibal Jodorcovsky sent me, which
is said to work in Windows 2000.

If wsaddr is NULL, probably wsaddrlen is too, so it doesn't matter if
*wsaddrlen is zero.  I think it makes sense to reorder the tests as I
have done.  I'm attaching one in case the inline one folds.

ChangeLog:
	dlls/winsock/socket.c:
	Lawson Whitney <lawson_whitney@juno.com>
	Protect against NULL wsaddrlen in ws_sockaddr_alloc.

diff -ur was/dlls/winsock/socket.c is/dlls/winsock/socket.c
--- was/dlls/winsock/socket.c	Tue Jan 29 18:29:07 2002
+++ is/dlls/winsock/socket.c	Wed Feb 13 16:44:47 2002
@@ -838,12 +838,12 @@
 /* allocates a Unix sockaddr structure to receive the data */
 inline struct sockaddr* ws_sockaddr_alloc(const struct WS_sockaddr* wsaddr, int* wsaddrlen, int* uaddrlen)
 {
+    if (wsaddr==NULL)
+        return NULL;
     if (*wsaddrlen==0)
         *uaddrlen=0;
     else
         *uaddrlen=max(sizeof(struct sockaddr),*wsaddrlen);
-    if (wsaddr==NULL)
-        return NULL;

     return malloc(*uaddrlen);
 }




diff -ur was/dlls/winsock/socket.c is/dlls/winsock/socket.c
--- was/dlls/winsock/socket.c	Tue Jan 29 18:29:07 2002
+++ is/dlls/winsock/socket.c	Wed Feb 13 16:44:47 2002
@@ -838,12 +838,12 @@
 /* allocates a Unix sockaddr structure to receive the data */
 inline struct sockaddr* ws_sockaddr_alloc(const struct WS_sockaddr* wsaddr, int* wsaddrlen, int* uaddrlen)
 {
+    if (wsaddr==NULL)
+        return NULL;
     if (*wsaddrlen==0)
         *uaddrlen=0;
     else
         *uaddrlen=max(sizeof(struct sockaddr),*wsaddrlen);
-    if (wsaddr==NULL)
-        return NULL;
 
     return malloc(*uaddrlen);
 }

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

  Powered by Linux