[hackers] [slock] applied andres' multi-slock fix, thanks for spotting this issue || garbeam

From: <hg_AT_suckless.org>
Date: Thu, 2 Aug 2012 21:54:21 +0200 (CEST)

changeset: 53:859881ad3471
tag: tip
user: garbeam_AT_gmail.com
date: Thu Aug 02 21:54:18 2012 +0200
files: slock.c
description:
applied andres' multi-slock fix, thanks for spotting this issue


diff -r 639240c84cb2 -r 859881ad3471 slock.c
--- a/slock.c Sun Apr 15 11:58:16 2012 +0200
+++ b/slock.c Thu Aug 02 21:54:18 2012 +0200
_AT_@ -1,3 +1,4 @@
+
 /* See LICENSE file for license details. */
 #define _XOPEN_SOURCE 500
 #if HAVE_SHADOW_H
_AT_@ -211,9 +212,9 @@
                                 break;
                         usleep(1000);
                 }
- running = (len > 0);
         }
 
+ running &= (len > 0);
         if(!running) {
                 unlockscreen(dpy, lock);
                 lock = NULL;
_AT_@ -257,10 +258,20 @@
         locks = malloc(sizeof(Lock *) * nscreens);
         if(locks == NULL)
                 die("slock: malloc: %s", strerror(errno));
- for(screen = 0; screen < nscreens; screen++)
- locks[screen] = lockscreen(dpy, screen);
+ int nlocks = 0;
+ for(screen = 0; screen < nscreens; screen++) {
+ if ( (locks[screen] = lockscreen(dpy, screen)) != NULL)
+ nlocks++;
+ }
         XSync(dpy, False);
 
+ /* Did we actually manage to lock something? */
+ if (nlocks == 0) { // nothing to protect
+ free(locks);
+ XCloseDisplay(dpy);
+ return 1;
+ }
+
         /* Everything is now blank. Now wait for the correct password. */
 #ifdef HAVE_BSD_AUTH
         readpw(dpy);
Received on Thu Aug 02 2012 - 21:54:21 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 02 2012 - 22:00:11 CEST