summaryrefslogtreecommitdiff
path: root/libexec/ftpd
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2006-10-18 21:46:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2006-10-18 21:46:10 +0000
commit405bc45bd3b35cb3ed8ed535af542cc7e7d8a132 (patch)
tree6813753582ff9277c1d5102e2baad19c36bfdcc5 /libexec/ftpd
parentafd9ed17d063652a52bf4e9eecd1a1cbe2b3b941 (diff)
Avoid double fclose() of a file if we exceed retries. Coverity ID 2669.
OK cloder@
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 52619ff1a96..3b3f967ed61 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.172 2006/10/18 21:23:28 deraadt Exp $ */
+/* $OpenBSD: ftpd.c,v 1.173 2006/10/18 21:46:09 millert Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -70,7 +70,7 @@ static const char copyright[] =
static const char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
#else
static const char rcsid[] =
- "$OpenBSD: ftpd.c,v 1.172 2006/10/18 21:23:28 deraadt Exp $";
+ "$OpenBSD: ftpd.c,v 1.173 2006/10/18 21:46:09 millert Exp $";
#endif
#endif /* not lint */
@@ -1375,7 +1375,7 @@ static FILE *
dataconn(char *name, off_t size, char *mode)
{
char sizebuf[32];
- FILE *file;
+ FILE *file = NULL;
int retry = 0;
in_port_t *p;
u_char *fa, *ha;
@@ -1454,6 +1454,8 @@ dataconn(char *name, off_t size, char *mode)
data_dest = his_addr;
usedefault = 1;
do {
+ if (file != NULL)
+ (void) fclose(file);
file = getdatasock(mode);
if (file == NULL) {
char hbuf[MAXHOSTNAMELEN], pbuf[10];
@@ -1515,7 +1517,6 @@ dataconn(char *name, off_t size, char *mode)
}
if (errno != EADDRINUSE)
break;
- (void) fclose(file);
sleep((unsigned) swaitint);
retry += swaitint;
} while (retry <= swaitmax);