diff options
author | Darren Tucker <dtucker@zip.com.au> | 2005-11-22 19:38:06 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2005-11-22 19:38:06 +1100 |
commit | 33f86bc2843b23c89f1b40e4250ced5b84e4c141 (patch) | |
tree | 6a3d0c2343298ad737495bc8731005c4400e2d15 /scp.c | |
parent | b736d8d8292cd2222e6ad37518d562026d87f1dd (diff) |
- 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.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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 |