RESEND: Handle shortened *optval arg. in WS_setsockopt / WS_SO_RCVTIMEO

Greg Turner gmturner007 at ameritech.net
Tue Sep 24 16:10:43 CDT 2002



Argh, wrapped! This time I enclosed it.

CHANGELOG

* dlls/winsock/socket.c: Greg Turner <gmturner007 at ameritech.net>
- accept time_t argument in WS_setsockopt/WS_SO_RCVTIMEO;
  translate to struct timeval for edification of setsockopt.

-- 
Greg Turner <gmturner007 at ameritech.net>

"Waiting periods are only a step. Registration is only a step.
The prohibition of private firearms is the goal."
  -U.S. Attorney General Janet Reno, December 1993

-------------- next part --------------
Index: dlls/winsock/socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.106
diff -u -r1.106 socket.c
--- dlls/winsock/socket.c	12 Sep 2002 17:56:30 -0000	1.106
+++ dlls/winsock/socket.c	24 Sep 2002 01:08:14 -0000
@@ -2670,6 +2670,7 @@
     {
 	struct	linger linger;
         int woptval;
+        struct timeval tval;
 
 	/* Is a privileged and useless operation, so we don't. */
 	if ((optname == WS_SO_DEBUG) && (level == WS_SOL_SOCKET)) {
@@ -2704,6 +2705,21 @@
                 optval= (char*) &woptval;
                 optlen=sizeof(int);
             }
+	    if (level == SOL_SOCKET && optname == SO_RCVTIMEO && optlen < sizeof(struct timeval)) {
+	        if (optlen == sizeof(time_t)) {
+	            /* Apparently WinSock will accept a shortened struct timeval.
+		       FIXME: should we do the same for SO_SNDTIMEO? */
+	            WARN("Short struct timeval in SO_RCVTIMEO: assuming time_t\n");
+		    tval.tv_sec = *(time_t*)optval;
+		    tval.tv_usec = 0;
+	            optlen = sizeof(struct timeval);
+	            optval = (char*)&tval;
+		} else {
+		    WARN("SO_RCVTIMEO for %d bytes is too small: ignored\n", optlen);
+		    close(fd);
+		    return 0;
+		}
+	    }
 	}
         if(optname == SO_RCVBUF && *(int*)optval < 2048) {
             WARN("SO_RCVBF for %d bytes is too small: ignored\n", *(int*)optval );


More information about the wine-patches mailing list