[BACK]Return to scp.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/scp.c between version 1.117 and 1.117.2.2

version 1.117, 2004/08/11 21:44:32 version 1.117.2.2, 2005/09/02 03:45:00
Line 108 
Line 108 
 static void  static void
 killchild(int signo)  killchild(int signo)
 {  {
         if (do_cmd_pid > 1)          if (do_cmd_pid > 1) {
                 kill(do_cmd_pid, signo);                  kill(do_cmd_pid, signo ? signo : SIGTERM);
                   waitpid(do_cmd_pid, NULL, 0);
           }
   
         _exit(1);          if (signo)
                   _exit(1);
           exit(1);
 }  }
   
 /*  /*
Line 182 
Line 186 
 }  }
   
 typedef struct {  typedef struct {
         int cnt;          size_t cnt;
         char *buf;          char *buf;
 } BUF;  } BUF;
   
Line 354 
Line 358 
 toremote(char *targ, int argc, char **argv)  toremote(char *targ, int argc, char **argv)
 {  {
         int i, len;          int i, len;
         char *bp, *host, *src, *suser, *thost, *tuser;          char *bp, *host, *src, *suser, *thost, *tuser, *arg;
   
         *targ++ = 0;          *targ++ = 0;
         if (*targ == 0)          if (*targ == 0)
                 targ = ".";                  targ = ".";
   
         if ((thost = strrchr(argv[argc - 1], '@'))) {          arg = xstrdup(argv[argc - 1]);
           if ((thost = strrchr(arg, '@'))) {
                 /* user@host */                  /* user@host */
                 *thost++ = 0;                  *thost++ = 0;
                 tuser = argv[argc - 1];                  tuser = arg;
                 if (*tuser == '\0')                  if (*tuser == '\0')
                         tuser = NULL;                          tuser = NULL;
         } else {          } else {
                 thost = argv[argc - 1];                  thost = arg;
                 tuser = NULL;                  tuser = NULL;
         }          }
   
Line 494 
Line 499 
         struct stat stb;          struct stat stb;
         static BUF buffer;          static BUF buffer;
         BUF *bp;          BUF *bp;
         off_t i, amt, result, statbytes;          off_t i, amt, statbytes;
         int fd, haderr, indx;          size_t result;
           int fd = -1, haderr, indx;
         char *last, *name, buf[2048];          char *last, *name, buf[2048];
         int len;          int len;
   
Line 570 
Line 576 
                         if (!haderr) {                          if (!haderr) {
                                 result = atomicio(read, fd, bp->buf, amt);                                  result = atomicio(read, fd, bp->buf, amt);
                                 if (result != amt)                                  if (result != amt)
                                         haderr = result >= 0 ? EIO : errno;                                          haderr = errno;
                         }                          }
                         if (haderr)                          if (haderr)
                                 (void) atomicio(vwrite, remout, bp->buf, amt);                                  (void) atomicio(vwrite, remout, bp->buf, amt);
                         else {                          else {
                                 result = atomicio(vwrite, remout, bp->buf, amt);                                  result = atomicio(vwrite, remout, bp->buf, amt);
                                 if (result != amt)                                  if (result != amt)
                                         haderr = result >= 0 ? EIO : errno;                                          haderr = errno;
                                 statbytes += result;                                  statbytes += result;
                         }                          }
                         if (limit_rate)                          if (limit_rate)
Line 712 
Line 718 
                 YES, NO, DISPLAYED                  YES, NO, DISPLAYED
         } wrerr;          } wrerr;
         BUF *bp;          BUF *bp;
         off_t i, j;          off_t i;
         int amt, count, exists, first, mask, mode, ofd, omode;          size_t j, count;
           int amt, exists, first, mask, mode, ofd, omode;
         off_t size, statbytes;          off_t size, statbytes;
         int setimes, targisdir, wrerrno = 0;          int setimes, targisdir, wrerrno = 0;
         char ch, *cp, *np, *targ, *why, *vect[1], buf[2048];          char ch, *cp, *np, *targ, *why, *vect[1], buf[2048];
Line 721 
Line 728 
   
 #define atime   tv[0]  #define atime   tv[0]
 #define mtime   tv[1]  #define mtime   tv[1]
 #define SCREWUP(str)    do { why = str; goto screwup; } while (0)  #define SCREWUP(str)    { why = str; goto screwup; }
   
         setimes = targisdir = 0;          setimes = targisdir = 0;
         mask = umask(0);          mask = umask(0);
Line 740 
Line 747 
                 targisdir = 1;                  targisdir = 1;
         for (first = 1;; first = 0) {          for (first = 1;; first = 0) {
                 cp = buf;                  cp = buf;
                 if (atomicio(read, remin, cp, 1) <= 0)                  if (atomicio(read, remin, cp, 1) != 1)
                         return;                          return;
                 if (*cp++ == '\n')                  if (*cp++ == '\n')
                         SCREWUP("unexpected <newline>");                          SCREWUP("unexpected <newline>");
Line 821 
Line 828 
                 }                  }
                 if (targisdir) {                  if (targisdir) {
                         static char *namebuf;                          static char *namebuf;
                         static int cursize;                          static size_t cursize;
                         size_t need;                          size_t need;
   
                         need = strlen(targ) + strlen(cp) + 250;                          need = strlen(targ) + strlen(cp) + 250;
Line 894 
Line 901 
                         count += amt;                          count += amt;
                         do {                          do {
                                 j = atomicio(read, remin, cp, amt);                                  j = atomicio(read, remin, cp, amt);
                                 if (j <= 0) {                                  if (j == 0) {
                                         run_err("%s", j ? strerror(errno) :                                          run_err("%s", j ? strerror(errno) :
                                             "dropped connection");                                              "dropped connection");
                                         exit(1);                                          exit(1);
Line 910 
Line 917 
                         if (count == bp->cnt) {                          if (count == bp->cnt) {
                                 /* Keep reading so we stay sync'd up. */                                  /* Keep reading so we stay sync'd up. */
                                 if (wrerr == NO) {                                  if (wrerr == NO) {
                                         j = atomicio(vwrite, ofd, bp->buf, count);                                          if (atomicio(vwrite, ofd, bp->buf,
                                         if (j != count) {                                              count) != count) {
                                                 wrerr = YES;                                                  wrerr = YES;
                                                 wrerrno = j >= 0 ? EIO : errno;                                                  wrerrno = errno;
                                         }                                          }
                                 }                                  }
                                 count = 0;                                  count = 0;
Line 923 
Line 930 
                 if (showprogress)                  if (showprogress)
                         stop_progress_meter();                          stop_progress_meter();
                 if (count != 0 && wrerr == NO &&                  if (count != 0 && wrerr == NO &&
                     (j = atomicio(vwrite, ofd, bp->buf, count)) != count) {                      atomicio(vwrite, ofd, bp->buf, count) != count) {
                         wrerr = YES;                          wrerr = YES;
                         wrerrno = j >= 0 ? EIO : errno;                          wrerrno = errno;
                 }                  }
                 if (wrerr == NO && ftruncate(ofd, size) != 0) {                  if (wrerr == NO && ftruncate(ofd, size) != 0) {
                         run_err("%s: truncate: %s", np, strerror(errno));                          run_err("%s: truncate: %s", np, strerror(errno));
Line 1054 
Line 1061 
                 errno = ENOTDIR;                  errno = ENOTDIR;
         }          }
         run_err("%s: %s", cp, strerror(errno));          run_err("%s: %s", cp, strerror(errno));
         exit(1);          killchild(0);
 }  }
   
 int  int

Legend:
Removed from v.1.117  
changed lines
  Added in v.1.117.2.2