From 350918e7be82fca046911073b360518173169255 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 22 Nov 2022 20:57:47 +0800 Subject: [PATCH] Adjust x_display_set_last_user_time for Xlib sign-extension * src/xterm.c (x_display_set_last_user_time): Adjust for Xlib sign extending fields in client messages to 64 bit long, which then break x_display_set_last_user_time after 24 days, as Time is unsigned long for historical reasons. (bug#59480) --- src/xterm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index 154f404e6b4..732fbf462c9 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7749,6 +7749,11 @@ 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 -- 2.39.5