[scp.c]
     avoid close(-1), as in rcp; ok cloder
This commit is contained in:
Darren Tucker 2005-11-22 19:38:06 +11:00
parent b736d8d829
commit 33f86bc284
2 changed files with 14 additions and 5 deletions

View File

@ -3,6 +3,9 @@
- deraadt@cvs.openbsd.org 2005/11/12 18:37:59 - deraadt@cvs.openbsd.org 2005/11/12 18:37:59
[ssh-add.c] [ssh-add.c]
space space
- deraadt@cvs.openbsd.org 2005/11/12 18:38:15
[scp.c]
avoid close(-1), as in rcp; ok cloder
20051120 20051120
- (dtucker) [openbsd-compat/openssl-compat.h] Add comment explaining what - (dtucker) [openbsd-compat/openssl-compat.h] Add comment explaining what
@ -3312,4 +3315,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
$Id: ChangeLog,v 1.3997 2005/11/22 08:37:08 dtucker Exp $ $Id: ChangeLog,v 1.3998 2005/11/22 08:38:06 dtucker Exp $

10
scp.c
View File

@ -71,7 +71,7 @@
*/ */
#include "includes.h" #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 "xmalloc.h"
#include "atomicio.h" #include "atomicio.h"
@ -571,7 +571,10 @@ syserr: run_err("%s: %s", name, strerror(errno));
if (response() < 0) if (response() < 0)
goto next; goto next;
if ((bp = allocbuf(&buffer, fd, 2048)) == NULL) { if ((bp = allocbuf(&buffer, fd, 2048)) == NULL) {
next: (void) close(fd); next: if (fd != -1) {
(void) close(fd);
fd = -1;
}
continue; continue;
} }
if (showprogress) if (showprogress)
@ -600,8 +603,11 @@ next: (void) close(fd);
if (showprogress) if (showprogress)
stop_progress_meter(); stop_progress_meter();
if (fd != -1) {
if (close(fd) < 0 && !haderr) if (close(fd) < 0 && !haderr)
haderr = errno; haderr = errno;
fd = -1;
}
if (!haderr) if (!haderr)
(void) atomicio(vwrite, remout, "", 1); (void) atomicio(vwrite, remout, "", 1);
else else