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

Diff for /src/usr.bin/ssh/sftp.c between version 1.144 and 1.145

version 1.144, 2013/05/16 09:08:41 version 1.145, 2013/05/17 00:13:14
Line 290 
Line 290 
                 /* XXX: quoting - rip quoting code from ftp? */                  /* XXX: quoting - rip quoting code from ftp? */
                 snprintf(buf, len, _PATH_LS " %s", args);                  snprintf(buf, len, _PATH_LS " %s", args);
                 local_do_shell(buf);                  local_do_shell(buf);
                 xfree(buf);                  free(buf);
         }          }
 }  }
   
Line 321 
Line 321 
         /* Derelativise */          /* Derelativise */
         if (p && p[0] != '/') {          if (p && p[0] != '/') {
                 abs_str = path_append(pwd, p);                  abs_str = path_append(pwd, p);
                 xfree(p);                  free(p);
                 return(abs_str);                  return(abs_str);
         } else          } else
                 return(p);                  return(p);
Line 531 
Line 531 
                 tmp = xstrdup(g.gl_pathv[i]);                  tmp = xstrdup(g.gl_pathv[i]);
                 if ((filename = basename(tmp)) == NULL) {                  if ((filename = basename(tmp)) == NULL) {
                         error("basename %s: %s", tmp, strerror(errno));                          error("basename %s: %s", tmp, strerror(errno));
                         xfree(tmp);                          free(tmp);
                         err = -1;                          err = -1;
                         goto out;                          goto out;
                 }                  }
Line 547 
Line 547 
                 } else {                  } else {
                         abs_dst = xstrdup(filename);                          abs_dst = xstrdup(filename);
                 }                  }
                 xfree(tmp);                  free(tmp);
   
                 if (!quiet)                  if (!quiet)
                         printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);                          printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
Line 560 
Line 560 
                             pflag || global_pflag) == -1)                              pflag || global_pflag) == -1)
                                 err = -1;                                  err = -1;
                 }                  }
                 xfree(abs_dst);                  free(abs_dst);
                 abs_dst = NULL;                  abs_dst = NULL;
         }          }
   
 out:  out:
         xfree(abs_src);          free(abs_src);
         globfree(&g);          globfree(&g);
         return(err);          return(err);
 }  }
Line 617 
Line 617 
                 tmp = xstrdup(g.gl_pathv[i]);                  tmp = xstrdup(g.gl_pathv[i]);
                 if ((filename = basename(tmp)) == NULL) {                  if ((filename = basename(tmp)) == NULL) {
                         error("basename %s: %s", tmp, strerror(errno));                          error("basename %s: %s", tmp, strerror(errno));
                         xfree(tmp);                          free(tmp);
                         err = -1;                          err = -1;
                         goto out;                          goto out;
                 }                  }
Line 633 
Line 633 
                 } else {                  } else {
                         abs_dst = make_absolute(xstrdup(filename), pwd);                          abs_dst = make_absolute(xstrdup(filename), pwd);
                 }                  }
                 xfree(tmp);                  free(tmp);
   
                 if (!quiet)                  if (!quiet)
                         printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);                          printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
Line 649 
Line 649 
         }          }
   
 out:  out:
         if (abs_dst)          free(abs_dst);
                 xfree(abs_dst);          free(tmp_dst);
         if (tmp_dst)  
                 xfree(tmp_dst);  
         globfree(&g);          globfree(&g);
         return(err);          return(err);
 }  }
Line 700 
Line 698 
                 /* Add any subpath that also needs to be counted */                  /* Add any subpath that also needs to be counted */
                 tmp = path_strip(path, strip_path);                  tmp = path_strip(path, strip_path);
                 m += strlen(tmp);                  m += strlen(tmp);
                 xfree(tmp);                  free(tmp);
   
                 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)                  if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
                         width = ws.ws_col;                          width = ws.ws_col;
Line 726 
Line 724 
   
                 tmp = path_append(path, d[n]->filename);                  tmp = path_append(path, d[n]->filename);
                 fname = path_strip(tmp, strip_path);                  fname = path_strip(tmp, strip_path);
                 xfree(tmp);                  free(tmp);
   
                 if (lflag & LS_LONG_VIEW) {                  if (lflag & LS_LONG_VIEW) {
                         if (lflag & (LS_NUMERIC_VIEW|LS_SI_UNITS)) {                          if (lflag & (LS_NUMERIC_VIEW|LS_SI_UNITS)) {
Line 738 
Line 736 
                                 lname = ls_file(fname, &sb, 1,                                  lname = ls_file(fname, &sb, 1,
                                     (lflag & LS_SI_UNITS));                                      (lflag & LS_SI_UNITS));
                                 printf("%s\n", lname);                                  printf("%s\n", lname);
                                 xfree(lname);                                  free(lname);
                         } else                          } else
                                 printf("%s\n", d[n]->longname);                                  printf("%s\n", d[n]->longname);
                 } else {                  } else {
Line 750 
Line 748 
                                 c++;                                  c++;
                 }                  }
   
                 xfree(fname);                  free(fname);
         }          }
   
         if (!(lflag & LS_LONG_VIEW) && (c != 1))          if (!(lflag & LS_LONG_VIEW) && (c != 1))
Line 820 
Line 818 
                         lname = ls_file(fname, g.gl_statv[i], 1,                          lname = ls_file(fname, g.gl_statv[i], 1,
                             (lflag & LS_SI_UNITS));                              (lflag & LS_SI_UNITS));
                         printf("%s\n", lname);                          printf("%s\n", lname);
                         xfree(lname);                          free(lname);
                 } else {                  } else {
                         printf("%-*s", colspace, fname);                          printf("%-*s", colspace, fname);
                         if (c >= columns) {                          if (c >= columns) {
Line 829 
Line 827 
                         } else                          } else
                                 c++;                                  c++;
                 }                  }
                 xfree(fname);                  free(fname);
         }          }
   
         if (!(lflag & LS_LONG_VIEW) && (c != 1))          if (!(lflag & LS_LONG_VIEW) && (c != 1))
Line 1346 
Line 1344 
                         break;                          break;
                 }                  }
                 if ((aa = do_stat(conn, tmp, 0)) == NULL) {                  if ((aa = do_stat(conn, tmp, 0)) == NULL) {
                         xfree(tmp);                          free(tmp);
                         err = 1;                          err = 1;
                         break;                          break;
                 }                  }
                 if (!(aa->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) {                  if (!(aa->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) {
                         error("Can't change directory: Can't check target");                          error("Can't change directory: Can't check target");
                         xfree(tmp);                          free(tmp);
                         err = 1;                          err = 1;
                         break;                          break;
                 }                  }
                 if (!S_ISDIR(aa->perm)) {                  if (!S_ISDIR(aa->perm)) {
                         error("Can't change directory: \"%s\" is not "                          error("Can't change directory: \"%s\" is not "
                             "a directory", tmp);                              "a directory", tmp);
                         xfree(tmp);                          free(tmp);
                         err = 1;                          err = 1;
                         break;                          break;
                 }                  }
                 xfree(*pwd);                  free(*pwd);
                 *pwd = tmp;                  *pwd = tmp;
                 break;                  break;
         case I_LS:          case I_LS:
Line 1496 
Line 1494 
   
         if (g.gl_pathc)          if (g.gl_pathc)
                 globfree(&g);                  globfree(&g);
         if (path1)          free(path1);
                 xfree(path1);          free(path2);
         if (path2)  
                 xfree(path2);  
   
         /* If an unignored error occurs in batch mode we should abort. */          /* If an unignored error occurs in batch mode we should abort. */
         if (err_abort && err != 0)          if (err_abort && err != 0)
Line 1608 
Line 1604 
                 complete_display(list, 0);                  complete_display(list, 0);
   
                 for (y = 0; list[y] != NULL; y++)                  for (y = 0; list[y] != NULL; y++)
                         xfree(list[y]);                          free(list[y]);
                 xfree(list);                  free(list);
                 return count;                  return count;
         }          }
   
Line 1622 
Line 1618 
         list[count] = NULL;          list[count] = NULL;
   
         if (count == 0) {          if (count == 0) {
                 xfree(list);                  free(list);
                 return 0;                  return 0;
         }          }
   
Line 1632 
Line 1628 
                 complete_display(list, 0);                  complete_display(list, 0);
   
         for (y = 0; list[y]; y++)          for (y = 0; list[y]; y++)
                 xfree(list[y]);                  free(list[y]);
         xfree(list);          free(list);
   
         if (tmp != NULL) {          if (tmp != NULL) {
                 tmplen = strlen(tmp);                  tmplen = strlen(tmp);
Line 1654 
Line 1650 
                         if (y > 0 && el_insertstr(el, argterm) == -1)                          if (y > 0 && el_insertstr(el, argterm) == -1)
                                 fatal("el_insertstr failed.");                                  fatal("el_insertstr failed.");
                 }                  }
                 xfree(tmp);                  free(tmp);
         }          }
   
         return count;          return count;
Line 1718 
Line 1714 
                 if (tmp[tmplen] == '/')                  if (tmp[tmplen] == '/')
                         pwdlen = tmplen + 1;    /* track last seen '/' */                          pwdlen = tmplen + 1;    /* track last seen '/' */
         }          }
         xfree(tmp);          free(tmp);
   
         if (g.gl_matchc == 0)          if (g.gl_matchc == 0)
                 goto out;                  goto out;
Line 1733 
Line 1729 
   
         tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc);          tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc);
         tmp = path_strip(tmp2, isabs ? NULL : remote_path);          tmp = path_strip(tmp2, isabs ? NULL : remote_path);
         xfree(tmp2);          free(tmp2);
   
         if (tmp == NULL)          if (tmp == NULL)
                 goto out;                  goto out;
Line 1795 
Line 1791 
                 if (i > 0 && el_insertstr(el, ins) == -1)                  if (i > 0 && el_insertstr(el, ins) == -1)
                         fatal("el_insertstr failed.");                          fatal("el_insertstr failed.");
         }          }
         xfree(tmp);          free(tmp);
   
  out:   out:
         globfree(&g);          globfree(&g);
Line 1821 
Line 1817 
         memcpy(line, lf->buffer, cursor);          memcpy(line, lf->buffer, cursor);
         line[cursor] = '\0';          line[cursor] = '\0';
         argv = makeargv(line, &carg, 1, &quote, &terminated);          argv = makeargv(line, &carg, 1, &quote, &terminated);
         xfree(line);          free(line);
   
         /* Get all the arguments on the line */          /* Get all the arguments on the line */
         len = lf->lastchar - lf->buffer;          len = lf->lastchar - lf->buffer;
Line 1833 
Line 1829 
         /* Ensure cursor is at EOL or a argument boundary */          /* Ensure cursor is at EOL or a argument boundary */
         if (line[cursor] != ' ' && line[cursor] != '\0' &&          if (line[cursor] != ' ' && line[cursor] != '\0' &&
             line[cursor] != '\n') {              line[cursor] != '\n') {
                 xfree(line);                  free(line);
                 return ret;                  return ret;
         }          }
   
Line 1861 
Line 1857 
                         ret = CC_REDISPLAY;                          ret = CC_REDISPLAY;
         }          }
   
         xfree(line);          free(line);
         return ret;          return ret;
 }  }
   
Line 1915 
Line 1911 
                         snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);                          snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);
                         if (parse_dispatch_command(conn, cmd,                          if (parse_dispatch_command(conn, cmd,
                             &remote_path, 1) != 0) {                              &remote_path, 1) != 0) {
                                 xfree(dir);                                  free(dir);
                                 xfree(remote_path);                                  free(remote_path);
                                 xfree(conn);                                  free(conn);
                                 return (-1);                                  return (-1);
                         }                          }
                 } else {                  } else {
Line 1930 
Line 1926 
   
                         err = parse_dispatch_command(conn, cmd,                          err = parse_dispatch_command(conn, cmd,
                             &remote_path, 1);                              &remote_path, 1);
                         xfree(dir);                          free(dir);
                         xfree(remote_path);                          free(remote_path);
                         xfree(conn);                          free(conn);
                         return (err);                          return (err);
                 }                  }
                 xfree(dir);                  free(dir);
         }          }
   
         setlinebuf(stdout);          setlinebuf(stdout);
Line 1990 
Line 1986 
                 if (err != 0)                  if (err != 0)
                         break;                          break;
         }          }
         xfree(remote_path);          free(remote_path);
         xfree(conn);          free(conn);
   
         if (el != NULL)          if (el != NULL)
                 el_end(el);                  el_end(el);

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.145