I noticed that chmod.c have uninitialized variable char *ep that was
used. This diff clarify what I mean.


 Index: chmod.c
===================================================================
RCS file: /OpenBSD/src/bin/chmod/chmod.c,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 chmod.c
--- chmod.c     21 May 2014 06:23:01 -0000      1.30
+++ chmod.c     24 Sep 2014 08:47:58 -0000
@@ -65,7 +65,7 @@ main(int argc, char *argv[])
        uid_t uid;
        gid_t gid;
        u_int32_t fclear, fset;
-       char *ep, *mode, *cp, *flags;
+       char *mode, *cp, *flags;
        setlocale(LC_ALL, "");
@@ -148,13 +148,11 @@ done:
                flags = *argv;
                if (*flags >= '0' && *flags <= '7') {
                        errno = 0;
-                       val = strtoul(flags, &ep, 8);
+                       val = strtoul(flags, (char *)NULL, 8);
                        if (val > UINT_MAX)
                                errno = ERANGE;
                        if (errno)
                                err(1, "invalid flags: %s", flags);
-                       if (*ep)
-                               errx(1, "invalid flags: %s", flags);
                        fset = val;
                        oct = 1;
                } else {
@@ -167,13 +165,11 @@ done:
                mode = *argv;
                if (*mode >= '0' && *mode <= '7') {
                        errno = 0;
-                       val = strtol(mode, &ep, 8);
+                       val = strtol(mode, (char *)NULL, 8);
                        if (val > INT_MAX || val < 0)
                                errno = ERANGE;
                        if (errno)
                                err(1, "invalid file mode: %s", mode);
-                       if (*ep)
-                               errx(1, "invalid file mode: %s", mode);
                        omode = val;
                        oct = 1;
                } else {

Reply via email to