=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/scp.c,v retrieving revision 1.117.2.2 retrieving revision 1.118 diff -u -r1.117.2.2 -r1.118 --- src/usr.bin/ssh/scp.c 2005/09/02 03:45:00 1.117.2.2 +++ src/usr.bin/ssh/scp.c 2004/09/15 18:46:04 1.118 @@ -71,7 +71,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.117.2.2 2005/09/02 03:45:00 brad Exp $"); +RCSID("$OpenBSD: scp.c,v 1.118 2004/09/15 18:46:04 deraadt Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -108,14 +108,10 @@ static void killchild(int signo) { - if (do_cmd_pid > 1) { - kill(do_cmd_pid, signo ? signo : SIGTERM); - waitpid(do_cmd_pid, NULL, 0); - } + if (do_cmd_pid > 1) + kill(do_cmd_pid, signo); - if (signo) - _exit(1); - exit(1); + _exit(1); } /* @@ -186,7 +182,7 @@ } typedef struct { - size_t cnt; + int cnt; char *buf; } BUF; @@ -358,21 +354,20 @@ toremote(char *targ, int argc, char **argv) { int i, len; - char *bp, *host, *src, *suser, *thost, *tuser, *arg; + char *bp, *host, *src, *suser, *thost, *tuser; *targ++ = 0; if (*targ == 0) targ = "."; - arg = xstrdup(argv[argc - 1]); - if ((thost = strrchr(arg, '@'))) { + if ((thost = strrchr(argv[argc - 1], '@'))) { /* user@host */ *thost++ = 0; - tuser = arg; + tuser = argv[argc - 1]; if (*tuser == '\0') tuser = NULL; } else { - thost = arg; + thost = argv[argc - 1]; tuser = NULL; } @@ -499,9 +494,8 @@ struct stat stb; static BUF buffer; BUF *bp; - off_t i, amt, statbytes; - size_t result; - int fd = -1, haderr, indx; + off_t i, amt, result, statbytes; + int fd, haderr, indx; char *last, *name, buf[2048]; int len; @@ -576,14 +570,14 @@ if (!haderr) { result = atomicio(read, fd, bp->buf, amt); if (result != amt) - haderr = errno; + haderr = result >= 0 ? EIO : errno; } if (haderr) (void) atomicio(vwrite, remout, bp->buf, amt); else { result = atomicio(vwrite, remout, bp->buf, amt); if (result != amt) - haderr = errno; + haderr = result >= 0 ? EIO : errno; statbytes += result; } if (limit_rate) @@ -718,9 +712,8 @@ YES, NO, DISPLAYED } wrerr; BUF *bp; - off_t i; - size_t j, count; - int amt, exists, first, mask, mode, ofd, omode; + off_t i, j; + int amt, count, exists, first, mask, mode, ofd, omode; off_t size, statbytes; int setimes, targisdir, wrerrno = 0; char ch, *cp, *np, *targ, *why, *vect[1], buf[2048]; @@ -747,7 +740,7 @@ targisdir = 1; for (first = 1;; first = 0) { cp = buf; - if (atomicio(read, remin, cp, 1) != 1) + if (atomicio(read, remin, cp, 1) <= 0) return; if (*cp++ == '\n') SCREWUP("unexpected "); @@ -828,7 +821,7 @@ } if (targisdir) { static char *namebuf; - static size_t cursize; + static int cursize; size_t need; need = strlen(targ) + strlen(cp) + 250; @@ -901,7 +894,7 @@ count += amt; do { j = atomicio(read, remin, cp, amt); - if (j == 0) { + if (j <= 0) { run_err("%s", j ? strerror(errno) : "dropped connection"); exit(1); @@ -917,10 +910,10 @@ if (count == bp->cnt) { /* Keep reading so we stay sync'd up. */ if (wrerr == NO) { - if (atomicio(vwrite, ofd, bp->buf, - count) != count) { + j = atomicio(vwrite, ofd, bp->buf, count); + if (j != count) { wrerr = YES; - wrerrno = errno; + wrerrno = j >= 0 ? EIO : errno; } } count = 0; @@ -930,9 +923,9 @@ if (showprogress) stop_progress_meter(); if (count != 0 && wrerr == NO && - atomicio(vwrite, ofd, bp->buf, count) != count) { + (j = atomicio(vwrite, ofd, bp->buf, count)) != count) { wrerr = YES; - wrerrno = errno; + wrerrno = j >= 0 ? EIO : errno; } if (wrerr == NO && ftruncate(ofd, size) != 0) { run_err("%s: truncate: %s", np, strerror(errno)); @@ -1061,7 +1054,7 @@ errno = ENOTDIR; } run_err("%s: %s", cp, strerror(errno)); - killchild(0); + exit(1); } int