summaryrefslogtreecommitdiffstats
path: root/scp.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2005-11-22 09:38:06 +0100
committerDarren Tucker <dtucker@zip.com.au>2005-11-22 09:38:06 +0100
commit33f86bc2843b23c89f1b40e4250ced5b84e4c141 (patch)
tree6a3d0c2343298ad737495bc8731005c4400e2d15 /scp.c
parent - deraadt@cvs.openbsd.org 2005/11/12 18:37:59 (diff)
downloadopenssh-33f86bc2843b23c89f1b40e4250ced5b84e4c141.tar.xz
openssh-33f86bc2843b23c89f1b40e4250ced5b84e4c141.zip
- deraadt@cvs.openbsd.org 2005/11/12 18:38:15
[scp.c] avoid close(-1), as in rcp; ok cloder
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/scp.c b/scp.c
index 58c00442f..59285abca 100644
--- a/scp.c
+++ b/scp.c
@@ -71,7 +71,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.126 2005/09/13 23:40:07 djm Exp $");
+RCSID("$OpenBSD: scp.c,v 1.127 2005/11/12 18:38:15 deraadt Exp $");
#include "xmalloc.h"
#include "atomicio.h"
@@ -571,7 +571,10 @@ syserr: run_err("%s: %s", name, strerror(errno));
if (response() < 0)
goto next;
if ((bp = allocbuf(&buffer, fd, 2048)) == NULL) {
-next: (void) close(fd);
+next: if (fd != -1) {
+ (void) close(fd);
+ fd = -1;
+ }
continue;
}
if (showprogress)
@@ -600,8 +603,11 @@ next: (void) close(fd);
if (showprogress)
stop_progress_meter();
- if (close(fd) < 0 && !haderr)
- haderr = errno;
+ if (fd != -1) {
+ if (close(fd) < 0 && !haderr)
+ haderr = errno;
+ fd = -1;
+ }
if (!haderr)
(void) atomicio(vwrite, remout, "", 1);
else