[hackers] [sbase] chmod: strnum || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Fri, 10 Jun 2011 06:44:05 +0200 (CEST)

changeset: 72:43a3e68f76e5
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Fri Jun 10 05:44:00 2011 +0100
files: chmod.c
description:
chmod: strnum

diff -r 1227130bdeae -r 43a3e68f76e5 chmod.c
--- a/chmod.c Fri Jun 10 05:41:40 2011 +0100
+++ b/chmod.c Fri Jun 10 05:44:00 2011 +0100
@@ -14,7 +14,7 @@
 int
 main(int argc, char *argv[])
 {
- char c, *end;
+ char c;
         int octal;
 
         while((c = getopt(argc, argv, "Rr")) != -1)
@@ -28,9 +28,7 @@
                 }
         if(optind == argc)
                 eprintf("usage: %s [-Rr] mode [file...]\n", argv[0]);
- octal = strtol(argv[optind++], &end, 8);
- if(*end != '\0')
- eprintf("%s: not an octal number\n", argv[optind-1]);
+ octal = strnum(argv[optind++], 8);
 
         /* posix doesn't specify modal bits */
         if(octal & 04000) mode |= S_ISUID;
Received on Fri Jun 10 2011 - 06:44:05 CEST

This archive was generated by hypermail 2.2.0 : Fri Jun 10 2011 - 06:48:05 CEST