diff options
author | Colin Watson <cjwatson@debian.org> | 2018-08-24 12:49:36 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-08-24 12:49:36 +0100 |
commit | e6547182a54f0f268ee36e7c99319eeddffbaff2 (patch) | |
tree | 417527229ad3f3764ba71ea383f478a168895087 /sftp-client.c | |
parent | ed6ae9c1a014a08ff5db3d768f01f2e427eeb476 (diff) | |
parent | 71508e06fab14bc415a79a08f5535ad7bffa93d9 (diff) |
Import openssh_7.8p1.orig.tar.gz
Diffstat (limited to 'sftp-client.c')
-rw-r--r-- | sftp-client.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sftp-client.c b/sftp-client.c index 0b53a2e68..4986d6d8d 100644 --- a/sftp-client.c +++ b/sftp-client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp-client.c,v 1.128 2017/11/28 21:10:22 dtucker Exp $ */ | 1 | /* $OpenBSD: sftp-client.c,v 1.130 2018/07/31 03:07:24 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -669,7 +669,7 @@ do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag, | |||
669 | **dir = NULL; | 669 | **dir = NULL; |
670 | } | 670 | } |
671 | 671 | ||
672 | return status; | 672 | return status == SSH2_FX_OK ? 0 : -1; |
673 | } | 673 | } |
674 | 674 | ||
675 | int | 675 | int |
@@ -1019,7 +1019,7 @@ do_fsync(struct sftp_conn *conn, u_char *handle, u_int handle_len) | |||
1019 | if (status != SSH2_FX_OK) | 1019 | if (status != SSH2_FX_OK) |
1020 | error("Couldn't sync file: %s", fx2txt(status)); | 1020 | error("Couldn't sync file: %s", fx2txt(status)); |
1021 | 1021 | ||
1022 | return status; | 1022 | return status == SSH2_FX_OK ? 0 : -1; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | #ifdef notyet | 1025 | #ifdef notyet |
@@ -1451,7 +1451,7 @@ do_download(struct sftp_conn *conn, const char *remote_path, | |||
1451 | sshbuf_free(msg); | 1451 | sshbuf_free(msg); |
1452 | free(handle); | 1452 | free(handle); |
1453 | 1453 | ||
1454 | return(status); | 1454 | return status == SSH2_FX_OK ? 0 : -1; |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | static int | 1457 | static int |
@@ -1461,7 +1461,7 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1461 | { | 1461 | { |
1462 | int i, ret = 0; | 1462 | int i, ret = 0; |
1463 | SFTP_DIRENT **dir_entries; | 1463 | SFTP_DIRENT **dir_entries; |
1464 | char *filename, *new_src, *new_dst; | 1464 | char *filename, *new_src = NULL, *new_dst = NULL; |
1465 | mode_t mode = 0777; | 1465 | mode_t mode = 0777; |
1466 | 1466 | ||
1467 | if (depth >= MAX_DIR_DEPTH) { | 1467 | if (depth >= MAX_DIR_DEPTH) { |
@@ -1499,8 +1499,10 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | for (i = 0; dir_entries[i] != NULL && !interrupted; i++) { | 1501 | for (i = 0; dir_entries[i] != NULL && !interrupted; i++) { |
1502 | filename = dir_entries[i]->filename; | 1502 | free(new_dst); |
1503 | free(new_src); | ||
1503 | 1504 | ||
1505 | filename = dir_entries[i]->filename; | ||
1504 | new_dst = path_append(dst, filename); | 1506 | new_dst = path_append(dst, filename); |
1505 | new_src = path_append(src, filename); | 1507 | new_src = path_append(src, filename); |
1506 | 1508 | ||
@@ -1523,9 +1525,9 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1523 | } else | 1525 | } else |
1524 | logit("%s: not a regular file\n", new_src); | 1526 | logit("%s: not a regular file\n", new_src); |
1525 | 1527 | ||
1526 | free(new_dst); | ||
1527 | free(new_src); | ||
1528 | } | 1528 | } |
1529 | free(new_dst); | ||
1530 | free(new_src); | ||
1529 | 1531 | ||
1530 | if (preserve_flag) { | 1532 | if (preserve_flag) { |
1531 | if (dirattrib->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { | 1533 | if (dirattrib->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { |
@@ -1793,7 +1795,7 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1793 | int ret = 0; | 1795 | int ret = 0; |
1794 | DIR *dirp; | 1796 | DIR *dirp; |
1795 | struct dirent *dp; | 1797 | struct dirent *dp; |
1796 | char *filename, *new_src, *new_dst; | 1798 | char *filename, *new_src = NULL, *new_dst = NULL; |
1797 | struct stat sb; | 1799 | struct stat sb; |
1798 | Attrib a, *dirattrib; | 1800 | Attrib a, *dirattrib; |
1799 | 1801 | ||
@@ -1844,6 +1846,8 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1844 | while (((dp = readdir(dirp)) != NULL) && !interrupted) { | 1846 | while (((dp = readdir(dirp)) != NULL) && !interrupted) { |
1845 | if (dp->d_ino == 0) | 1847 | if (dp->d_ino == 0) |
1846 | continue; | 1848 | continue; |
1849 | free(new_dst); | ||
1850 | free(new_src); | ||
1847 | filename = dp->d_name; | 1851 | filename = dp->d_name; |
1848 | new_dst = path_append(dst, filename); | 1852 | new_dst = path_append(dst, filename); |
1849 | new_src = path_append(src, filename); | 1853 | new_src = path_append(src, filename); |
@@ -1870,9 +1874,9 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, | |||
1870 | } | 1874 | } |
1871 | } else | 1875 | } else |
1872 | logit("%s: not a regular file\n", filename); | 1876 | logit("%s: not a regular file\n", filename); |
1873 | free(new_dst); | ||
1874 | free(new_src); | ||
1875 | } | 1877 | } |
1878 | free(new_dst); | ||
1879 | free(new_src); | ||
1876 | 1880 | ||
1877 | do_setstat(conn, dst, &a); | 1881 | do_setstat(conn, dst, &a); |
1878 | 1882 | ||