]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve last change to xterm.c
authorPo Lu <luangruo@yahoo.com>
Wed, 23 Nov 2022 12:36:39 +0000 (20:36 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 23 Nov 2022 12:40:35 +0000 (20:40 +0800)
* src/xfns.c (Fx_display_last_user_time): Reject overly large
timestamps.
* src/xterm.c (x_display_set_last_user_time, handle_one_xevent):
New functions.

src/xfns.c
src/xterm.c

index 95092ce05f479151d2bafb805150118da3e402dd..fa2c0751d9007ce84557a8d134b7d126efda5708 100644 (file)
@@ -9728,10 +9728,12 @@ selected frame's display.  */)
   (Lisp_Object time_object, Lisp_Object terminal)
 {
   struct x_display_info *dpyinfo;
-  Time time;
+  uint32_t time;
 
+  /* time should be a 32-bit integer, regardless of what the size of
+     the X type `Time' is on this system.  */
   dpyinfo = check_x_display_info (terminal);
-  CONS_TO_INTEGER (time_object, Time, time);
+  CONS_TO_INTEGER (time_object, uint32_t, time);
 
   x_set_last_user_time_from_lisp (dpyinfo, time);
   return Qnil;
index 732fbf462c9c37b3f8c88683579bc576cf5e9e06..cfd8c385d1dfec58a573d8358821f21c71d31d50 100644 (file)
@@ -7749,11 +7749,6 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time,
   old_time = dpyinfo->last_user_time;
 #endif
 
-  /* Time can be sign extended if retrieved from a client message.
-     Make sure it is always 32 bits, or systems with 64-bit longs
-     will crash after 24 days of X server uptime.  (bug#59480) */
-  time &= X_ULONG_MAX;
-
 #ifdef ENABLE_CHECKING
   eassert (time <= X_ULONG_MAX);
 #endif
@@ -18626,7 +18621,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                /* Set the provided time as the user time, which is
                   required for SetInputFocus to work correctly after
                   taking the input focus.  */
-               x_display_set_last_user_time (dpyinfo, event->xclient.data.l[1],
+
+               /* Time can be sign extended if retrieved from a client message.
+                  Make sure it is always 32 bits, or systems with 64-bit longs
+                  will crash after 24 days of X server uptime.  (bug#59480) */
+               x_display_set_last_user_time (dpyinfo, (event->xclient.data.l[1]
+                                                       & 0xffffffff),
                                              true, true);
                goto done;
               }