Module Name: src
Committed By: shm
Date: Mon Aug 10 07:32:49 UTC 2015
Modified Files:
src/libexec/ftpd: cmds.c ftpd.c
Log Message:
Fix directory stream leaks
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/libexec/ftpd/cmds.c
cvs rdiff -u -r1.201 -r1.202 src/libexec/ftpd/ftpd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/ftpd/cmds.c
diff -u src/libexec/ftpd/cmds.c:1.33 src/libexec/ftpd/cmds.c:1.34
--- src/libexec/ftpd/cmds.c:1.33 Wed Jul 3 14:15:47 2013
+++ src/libexec/ftpd/cmds.c Mon Aug 10 07:32:49 2015
@@ -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 @@ mlsd(const char *path)
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;
Index: src/libexec/ftpd/ftpd.c
diff -u src/libexec/ftpd/ftpd.c:1.201 src/libexec/ftpd/ftpd.c:1.202
--- src/libexec/ftpd/ftpd.c:1.201 Sun Jan 25 15:53:49 2015
+++ src/libexec/ftpd/ftpd.c Mon Aug 10 07:32:49 2015
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
#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 @@ send_file_list(const char *whichf)
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 @@ send_file_list(const char *whichf)
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;