emacs-diffs
[Top][All Lists]
Advanced

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

master 088b81031b: Fix the MS-Windows build


From: Eli Zaretskii
Subject: master 088b81031b: Fix the MS-Windows build
Date: Tue, 6 Sep 2022 08:10:05 -0400 (EDT)

branch: master
commit 088b81031b8873f898cc611d73d1d2d55eb3c942
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix the MS-Windows build
    
    * lib-src/emacsclient.c (DEFAULT_TIMEOUT): Move out of the
    !WINDOWSNT condition, to fix the MS-Windows compilation.
    (set_socket_timeout) [WINDOWSNT]: Protect against too-large values
    of timeout.
---
 lib-src/emacsclient.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 15acb4589a..2e5d8d0cc2 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -55,8 +55,6 @@ char *w32_getenv (const char *);
 # include <sys/socket.h>
 # include <sys/un.h>
 
-# define DEFAULT_TIMEOUT (30)
-
 # define SOCKETS_IN_FILE_SYSTEM
 
 # define INVALID_SOCKET (-1)
@@ -68,6 +66,8 @@ char *w32_getenv (const char *);
 
 #endif /* !WINDOWSNT */
 
+#define DEFAULT_TIMEOUT (30)
+
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
@@ -1898,7 +1898,12 @@ set_socket_timeout (HSOCKET socket, int seconds)
   timeout.tv_usec = 0;
   setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);
 #else
-  DWORD timeout = seconds * 1000;
+  DWORD timeout;
+
+  if (seconds > INT_MAX / 1000)
+    timeout = INT_MAX;
+  else
+    timeout = seconds * 1000;
   setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof 
timeout);
 #endif
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]