[hackers] [sbase] Fix potential exit status wraparound in chgrp(1) || sin

From: <git_AT_suckless.org>
Date: Sat, 22 Nov 2014 12:15:01 +0100

commit bf8e37625ac2379fc6fc17caafd9b8875d8a98aa
Author: sin <sin_AT_2f30.org>
Date: Sat Nov 22 11:13:53 2014 +0000

    Fix potential exit status wraparound in chgrp(1)

diff --git a/chgrp.c b/chgrp.c
index b052bba..78ee68b 100644
--- a/chgrp.c
+++ b/chgrp.c
_AT_@ -11,8 +11,8 @@
 #include "util.h"
 
 static int gid;
-static int failures = 0;
-static int rflag = 0;
+static int status;
+static int rflag;
 static struct stat st;
 
 static void
_AT_@ -26,7 +26,7 @@ chgrp(const char *path)
 {
         if (chown(path, st.st_uid, gid) < 0) {
                 weprintf("chown %s:", path);
- failures++;
+ status = 1;
         }
         if (rflag)
                 recurse(path, chgrp);
_AT_@ -59,11 +59,10 @@ main(int argc, char *argv[])
         while (*++argv) {
                 if (stat(*argv, &st) < 0) {
                         weprintf("stat %s:", *argv);
- failures++;
+ status = 1;
                         continue;
                 }
                 chgrp(*argv);
         }
-
- return failures;
+ return status;
 }
Received on Sat Nov 22 2014 - 12:15:01 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 22 2014 - 12:24:10 CET