Package: xscreensaver
Version: 4.24-5.nix.1
Severity: normal
Tags: patch

If the machine is suspended (using swsusp or similar) while xscreensaver
is fading in or out, and the machine stays in suspended state more
than cca. 72 minutes, an overflow occurs in the code that computes the
sleep time between fade steps, which results in xscreensaver sleeping
for many minutes (without responding to either keyboard, mouse or
xscreensaver-command socket).

Since it is normal to lock the screen before suspending the machine
(eg. the hibernate script has an option that does this automatically),
the probability is high. The only prerequisite is enablig the 'fade'
option of xscreensaver.

A patch is attached (it produces a couple of duplicated code lines, though).

Best regards,

norbi


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (700, 'stable'), (660, 'oldstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18
Locale: LANG=C, LC_CTYPE=hu_HU (charmap=ISO-8859-2)

Versions of packages xscreensaver depends on:
ii  libatk1.0-0            1.12.4-3          The ATK accessibility toolkit
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  libcairo2              1.2.4-4           The Cairo 2D vector graphics libra
ii  libfontconfig1         2.4.2-1.2         generic font configuration library
ii  libglade2-0            1:2.6.0-4         library to load .glade files at ru
ii  libglib2.0-0           2.12.4-2          The GLib library of C routines
ii  libgtk2.0-0            2.8.20-7          The GTK+ graphical user interface 
ii  libice6                1:1.0.1-2         X11 Inter-Client Exchange library
ii  libjpeg62              6b-13             The Independent JPEG Group's JPEG 
ii  libpam0g               0.79-4            Pluggable Authentication Modules l
ii  libpango1.0-0          1.14.8-5          Layout and rendering of internatio
ii  libsm6                 1:1.0.1-3         X11 Session Management library
ii  libx11-6               2:1.0.3-7         X11 client-side library
ii  libxcursor1            1.1.7-4           X cursor management library
ii  libxext6               1:1.0.1-2         X11 miscellaneous extension librar
ii  libxfixes3             1:4.0.1-5         X11 miscellaneous 'fixes' extensio
ii  libxi6                 1:1.0.1-4         X11 Input extension library
ii  libxinerama1           1:1.0.1-4.1       X11 Xinerama extension library
ii  libxml2                2.6.27.dfsg-1     GNOME XML library
ii  libxmu6                1:1.0.2-2         X11 miscellaneous utility library
ii  libxpm4                1:3.5.5-2         X11 pixmap library
ii  libxrandr2             2:1.1.0.2-5       X11 RandR extension library
ii  libxrender1            1:0.9.1-3         X Rendering Extension client libra
ii  libxt6                 1:1.0.2-2         X11 toolkit intrinsics library
ii  libxxf86misc1          1:1.0.1-2         X11 XFree86 miscellaneous extensio
ii  libxxf86vm1            1:1.0.1-2         X11 XFree86 video mode extension l

Versions of packages xscreensaver recommends:
ii  libjpeg-progs             6b-13          Programs for manipulating JPEG fil
ii  miscfiles [wordlist]      1.4.2.dfsg.1-7 Dictionaries and other interesting
ii  perl [perl5]              5.8.8-7etch1   Larry Wall's Practical Extraction 
ii  wamerican [wordlist]      6-2            American English dictionary words 
ii  xli                       1.17.0-22      command line tool for viewing imag
ii  xloadimage                4.1-16         Graphics file viewer under X11

-- no debconf information
diff -Naur xscreensaver-4.24/utils/fade.c xscreensaver-4.24-fixed/utils/fade.c
--- xscreensaver-4.24/utils/fade.c	2005-06-22 01:47:48.000000000 +0200
+++ xscreensaver-4.24-fixed/utils/fade.c	2007-10-03 21:07:25.000000000 +0200
@@ -12,6 +12,7 @@
 #include "utils.h"
 
 #include <sys/time.h> /* for gettimeofday() */
+#include <limits.h>
 
 #ifdef VMS
 # include "vms-gtod.h"
@@ -330,12 +331,14 @@
       /* If we haven't already used up our alotted time, sleep to avoid
 	 changing the colormap too fast. */
       {
-	long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
-		     now.tv_usec - then.tv_usec);
+	if ((now.tv_sec - then.tv_sec) < (LONG_MAX / 1000000 - 1)) {
+	  long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
+		       now.tv_usec - then.tv_usec);
+	  if (usecs_per_step > diff)
+	    usleep (usecs_per_step - diff);
+	}
 	then.tv_sec = now.tv_sec;
 	then.tv_usec = now.tv_usec;
-	if (usecs_per_step > diff)
-	  usleep (usecs_per_step - diff);
       }
     }
 
@@ -531,12 +534,14 @@
 	  /* If we haven't already used up our alotted time, sleep to avoid
 	     changing the colormap too fast. */
 	  {
-	    long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
-			 now.tv_usec - then.tv_usec);
+	    if ((now.tv_sec - then.tv_sec) < (LONG_MAX / 1000000 - 1)) {
+	      long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
+			   now.tv_usec - then.tv_usec);
+	      if (usecs_per_step > diff)
+		usleep (usecs_per_step - diff);
+	    }
 	    then.tv_sec = now.tv_sec;
 	    then.tv_usec = now.tv_usec;
-	    if (usecs_per_step > diff)
-	      usleep (usecs_per_step - diff);
 	  }
 	}
     }
@@ -758,12 +763,14 @@
 	  /* If we haven't already used up our alotted time, sleep to avoid
 	     changing the colormap too fast. */
 	  {
-	    long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
-			 now.tv_usec - then.tv_usec);
+	    if ((now.tv_sec - then.tv_sec) < (LONG_MAX / 1000000 - 1)) {
+	      long diff = (((now.tv_sec - then.tv_sec) * 1000000) +
+			   now.tv_usec - then.tv_usec);
+	      if (usecs_per_step > diff)
+		usleep (usecs_per_step - diff);
+	    }
 	    then.tv_sec = now.tv_sec;
 	    then.tv_usec = now.tv_usec;
-	    if (usecs_per_step > diff)
-	      usleep (usecs_per_step - diff);
 	  }
 	}
     }

Reply via email to