summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 18:38:16 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 18:38:16 +0000
commit99efa81edf241fc3299f83ee5c0647460450e079 (patch)
tree9ce22a76029d8e00ca3f830c2d6ad1bb0a370567 /usr.bin/ssh
parent7f6902edcbcc8bed1b744077678924306d2921d3 (diff)
avoid close(-1), as in rcp; ok cloder
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/scp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index 9a6c5288399..a523299a6c4 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/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"
@@ -566,7 +566,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)
@@ -595,8 +598,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