Source-Changes-HG archive

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

[src/trunk]: src/libexec/ftpd Fix directory stream leaks



details:   https://anonhg.NetBSD.org/src/rev/843a36524957
branches:  trunk
changeset: 339792:843a36524957
user:      shm <shm%NetBSD.org@localhost>
date:      Mon Aug 10 07:32:49 2015 +0000

description:
Fix directory stream leaks

diffstat:

 libexec/ftpd/cmds.c |   8 +++++---
 libexec/ftpd/ftpd.c |  12 ++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r 3175407c635c -r 843a36524957 libexec/ftpd/cmds.c
--- a/libexec/ftpd/cmds.c       Mon Aug 10 06:09:30 2015 +0000
+++ b/libexec/ftpd/cmds.c       Mon Aug 10 07:32:49 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $       */
+/*     $NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $    */
 
 /*
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.34 2015/08/10 07:32:49 shm Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -249,8 +249,10 @@
                goto mlsdperror;
 
        dout = dataconn("MLSD", (off_t)-1, "w");
-       if (dout == NULL)
+       if (dout == NULL) {
+               (void) closedir(dirp);
                return;
+       }
 
        memset(&f, 0, sizeof(f));
        f.stat = &sb;
diff -r 3175407c635c -r 843a36524957 libexec/ftpd/ftpd.c
--- a/libexec/ftpd/ftpd.c       Mon Aug 10 06:09:30 2015 +0000
+++ b/libexec/ftpd/ftpd.c       Mon Aug 10 07:32:49 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $      */
+/*     $NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $   */
 
 /*
  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #if 0
 static char sccsid[] = "@(#)ftpd.c     8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ftpd.c,v 1.201 2015/01/25 15:53:49 christos Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.202 2015/08/10 07:32:49 shm Exp $");
 #endif
 #endif /* not lint */
 
@@ -3482,8 +3482,10 @@
                while ((dir = readdir(dirp)) != NULL) {
                        char nbuf[MAXPATHLEN];
 
-                       if (urgflag && handleoobcmd())
+                       if (urgflag && handleoobcmd()) {
+                               (void) closedir(dirp);
                                goto cleanup_send_file_list;
+                       }
 
                        if (ISDOTDIR(dir->d_name) || ISDOTDOTDIR(dir->d_name))
                                continue;
@@ -3506,8 +3508,10 @@
                                if (dout == NULL) {
                                        dout = dataconn("file list", (off_t)-1,
                                                "w");
-                                       if (dout == NULL)
+                                       if (dout == NULL) {
+                                               (void) closedir(dirp);
                                                goto cleanup_send_file_list;
+                                       }
                                        transflag = 1;
                                }
                                p = nbuf;



Home | Main Index | Thread Index | Old Index