Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ftpd: minor changes



Hi,
here is a small patch for ftpd.

1. If one of these stat() fail, st1 and/or st2 are not initialized.
2. Since fatal() calls _exit(), 'ng' is useless.
3. 'b' will be defined in the if{}/elseif{}/else{}.
4. 'errno' is already initialized above.

Ok/Comments?


Index: cmds.c
===================================================================
RCS file: /cvsroot/src/libexec/ftpd/cmds.c,v
retrieving revision 1.31
diff -u -r1.31 cmds.c
--- cmds.c      19 Jun 2012 06:06:34 -0000      1.31
+++ cmds.c      2 Jul 2013 20:27:16 -0000
@@ -951,8 +951,8 @@
                tp[strlen(tp) - 1] = '\0';
 
        /* check that the path is correct */
-       stat(tp, &st1);
-       stat(".", &st2);
+       if ((stat(tp, &st1) == -1) || (stat(".", &st2) == -1))
+               goto bad;
        if ((st1.st_dev != st2.st_dev) || (st1.st_ino != st2.st_ino))
                goto bad;
 
Index: ftpd.c
===================================================================
RCS file: /cvsroot/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.198
diff -u -r1.198 ftpd.c
--- ftpd.c      19 Jun 2012 06:06:34 -0000      1.198
+++ ftpd.c      2 Jul 2013 20:27:17 -0000
@@ -1135,7 +1135,7 @@
 
                                        /* have a group specifier */
                if ((p = strchr(word, ':')) != NULL) {
-                       gid_t   *groups, *ng;
+                       gid_t   *groups;
                        int      gsize, i, found;
 
                        if (pw == NULL)
@@ -1144,11 +1144,10 @@
                        groups = NULL;
                        gsize = 16;
                        do {
-                               ng = realloc(groups, gsize * sizeof(gid_t));
-                               if (ng == NULL)
+                               groups = realloc(groups, gsize * sizeof(gid_t));
+                               if (groups == NULL)
                                        fatal(
                                            "Local resource failure: realloc");
-                               groups = ng;
                        } while (getgrouplist(pw->pw_name, pw->pw_gid,
                                                groups, &gsize) == -1);
                        found = 0;
@@ -2830,7 +2829,6 @@
        size_t  b;
        va_list ap;
 
-       b = 0;
        if (n == 0)
                b = snprintf(msg, sizeof(msg), "    ");
        else if (n < 0)
@@ -3264,7 +3262,6 @@
        (void)strtoul(result[2], &p, 10);
        if (errno || !*result[2] || *p)
                goto parsefail;
-       errno = 0;
        p = NULL;
        proto = strtoul(result[0], &p, 10);
        if (errno || !*result[0] || *p)


Home | Main Index | Thread Index | Old Index