From 99efa81edf241fc3299f83ee5c0647460450e079 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 12 Nov 2005 18:38:16 +0000 Subject: avoid close(-1), as in rcp; ok cloder --- usr.bin/ssh/scp.c | 14 ++++++++++---- 1 file 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 -- cgit v1.2.3