diff options
author | 2006-10-18 21:46:09 +0000 | |
---|---|---|
committer | 2006-10-18 21:46:09 +0000 | |
commit | 85df27d1cd2632039eca049939ec328baf2f57e8 (patch) | |
tree | bdf98da20b4c9ca4248c4a29a2dc64536356c1f6 | |
parent | you do not call fclose() on a file descriptor; ok cloder (diff) | |
download | wireguard-openbsd-85df27d1cd2632039eca049939ec328baf2f57e8.tar.xz wireguard-openbsd-85df27d1cd2632039eca049939ec328baf2f57e8.zip |
Avoid double fclose() of a file if we exceed retries. Coverity ID 2669.
OK cloder@
-rw-r--r-- | libexec/ftpd/ftpd.c | 9 |
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); |