Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/crypto/external/bsd/openssh/dist/sftp-client.c,v rcsdiff: /ftp/cvs/cvsroot/src/crypto/external/bsd/openssh/dist/sftp-client.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.20.2.2 retrieving revision 1.21 diff -u -p -r1.20.2.2 -r1.21 --- src/crypto/external/bsd/openssh/dist/sftp-client.c 2020/04/13 07:45:20 1.20.2.2 +++ src/crypto/external/bsd/openssh/dist/sftp-client.c 2018/08/26 07:46:36 1.21 @@ -1,5 +1,6 @@ -/* $NetBSD: sftp-client.c,v 1.20.2.2 2020/04/13 07:45:20 martin Exp $ */ -/* $OpenBSD: sftp-client.c,v 1.135 2019/10/04 04:31:59 djm Exp $ */ +/* $NetBSD: sftp-client.c,v 1.21 2018/08/26 07:46:36 christos Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.130 2018/07/31 03:07:24 djm Exp $ */ + /* * Copyright (c) 2001-2004 Damien Miller * @@ -22,7 +23,7 @@ /* XXX: copy between two remote sites */ #include "includes.h" -__RCSID("$NetBSD: sftp-client.c,v 1.20.2.2 2020/04/13 07:45:20 martin Exp $"); +__RCSID("$NetBSD: sftp-client.c,v 1.21 2018/08/26 07:46:36 christos Exp $"); #include /* MIN MAX */ #include @@ -77,7 +78,6 @@ struct sftp_conn { #define SFTP_EXT_FSTATVFS 0x00000004 #define SFTP_EXT_HARDLINK 0x00000008 #define SFTP_EXT_FSYNC 0x00000010 -#define SFTP_EXT_LSETSTAT 0x00000020 u_int exts; u_int64_t limit_kbps; struct bwlimit bwlimit_in, bwlimit_out; @@ -93,9 +93,7 @@ sftpio(void *_bwlimit, size_t amount) { struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit; - refresh_progress_meter(0); - if (bwlimit != NULL) - bandwidth_limit(bwlimit, amount); + bandwidth_limit(bwlimit, amount); return 0; } @@ -115,8 +113,8 @@ send_msg(struct sftp_conn *conn, struct iov[1].iov_base = __UNCONST(sshbuf_ptr(m)); iov[1].iov_len = sshbuf_len(m); - if (atomiciov6(writev, conn->fd_out, iov, 2, sftpio, - conn->limit_kbps > 0 ? &conn->bwlimit_out : NULL) != + if (atomiciov6(writev, conn->fd_out, iov, 2, + conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_out) != sshbuf_len(m) + sizeof(mlen)) fatal("Couldn't send packet: %s", strerror(errno)); @@ -132,8 +130,8 @@ get_msg_extended(struct sftp_conn *conn, if ((r = sshbuf_reserve(m, 4, &p)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); - if (atomicio6(read, conn->fd_in, p, 4, sftpio, - conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL) != 4) { + if (atomicio6(read, conn->fd_in, p, 4, + conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != 4) { if (errno == EPIPE || errno == ECONNRESET) fatal("Connection closed"); else @@ -151,8 +149,8 @@ get_msg_extended(struct sftp_conn *conn, if ((r = sshbuf_reserve(m, msg_len, &p)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); - if (atomicio6(read, conn->fd_in, p, msg_len, sftpio, - conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL) + if (atomicio6(read, conn->fd_in, p, msg_len, + conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != msg_len) { if (errno == EPIPE) fatal("Connection closed"); @@ -457,10 +455,6 @@ do_init(int fd_in, int fd_out, u_int tra strcmp((char *)value, "1") == 0) { ret->exts |= SFTP_EXT_FSYNC; known = 1; - } else if (strcmp(name, "lsetstat@openssh.com") == 0 && - strcmp((char *)value, "1") == 0) { - ret->exts |= SFTP_EXT_LSETSTAT; - known = 1; } if (known) { debug2("Server supports extension \"%s\" revision %s", @@ -622,7 +616,8 @@ do_lsreaddir(struct sftp_conn *conn, con __func__, ssh_err(r)); free(filename); free(longname); - goto out; + sshbuf_free(msg); + return -1; } if (print_flag) @@ -1093,6 +1088,7 @@ do_statvfs(struct sftp_conn *conn, const if ((msg = sshbuf_new()) == NULL) fatal("%s: sshbuf_new failed", __func__); + sshbuf_reset(msg); if ((r = sshbuf_put_u8(msg, SSH2_FXP_EXTENDED)) != 0 || (r = sshbuf_put_u32(msg, id)) != 0 || (r = sshbuf_put_cstring(msg, "statvfs@openssh.com")) != 0 || @@ -1121,6 +1117,7 @@ do_fstatvfs(struct sftp_conn *conn, cons if ((msg = sshbuf_new()) == NULL) fatal("%s: sshbuf_new failed", __func__); + sshbuf_reset(msg); if ((r = sshbuf_put_u8(msg, SSH2_FXP_EXTENDED)) != 0 || (r = sshbuf_put_u32(msg, id)) != 0 || (r = sshbuf_put_cstring(msg, "fstatvfs@openssh.com")) != 0 || @@ -1133,38 +1130,6 @@ do_fstatvfs(struct sftp_conn *conn, cons } #endif -int -do_lsetstat(struct sftp_conn *conn, const char *path, Attrib *a) -{ - struct sshbuf *msg; - u_int status, id; - int r; - - if ((conn->exts & SFTP_EXT_LSETSTAT) == 0) { - error("Server does not support lsetstat@openssh.com extension"); - return -1; - } - - id = conn->msg_id++; - if ((msg = sshbuf_new()) == NULL) - fatal("%s: sshbuf_new failed", __func__); - if ((r = sshbuf_put_u8(msg, SSH2_FXP_EXTENDED)) != 0 || - (r = sshbuf_put_u32(msg, id)) != 0 || - (r = sshbuf_put_cstring(msg, "lsetstat@openssh.com")) != 0 || - (r = sshbuf_put_cstring(msg, path)) != 0 || - (r = encode_attrib(msg, a)) != 0) - fatal("%s: buffer error: %s", __func__, ssh_err(r)); - send_msg(conn, msg); - sshbuf_free(msg); - - status = get_status(conn, id); - if (status != SSH2_FX_OK) - error("Couldn't setstat on \"%s\": %s", path, - fx2txt(status)); - - return status == SSH2_FX_OK ? 0 : -1; -} - static void send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset, u_int len, const u_char *handle, u_int handle_len) @@ -1174,6 +1139,7 @@ send_read_request(struct sftp_conn *conn if ((msg = sshbuf_new()) == NULL) fatal("%s: sshbuf_new failed", __func__); + sshbuf_reset(msg); if ((r = sshbuf_put_u8(msg, SSH2_FXP_READ)) != 0 || (r = sshbuf_put_u32(msg, id)) != 0 || (r = sshbuf_put_string(msg, handle, handle_len)) != 0 || @@ -1193,7 +1159,7 @@ do_download(struct sftp_conn *conn, cons struct sshbuf *msg; u_char *handle; int local_fd = -1, write_error; - int read_error, write_errno, lmodified = 0, reordered = 0, r; + int read_error, write_errno, reordered = 0, r; u_int64_t offset = 0, size, highwater; u_int mode, id, buflen, num_req, max_req, status = SSH2_FX_OK; off_t progress_counter; @@ -1364,7 +1330,6 @@ do_download(struct sftp_conn *conn, cons if (len > req->len) fatal("Received more data than asked for " "%zu > %zu", len, req->len); - lmodified = 1; if ((lseek(local_fd, req->offset, SEEK_SET) == -1 || atomicio(vwrite, local_fd, data, len) != len) && !write_error) { @@ -1464,9 +1429,7 @@ do_download(struct sftp_conn *conn, cons error("Can't set times on \"%s\": %s", local_path, strerror(errno)); } - if (resume_flag && !lmodified) - logit("File \"%s\" was not modified", local_path); - else if (fsync_flag) { + if (fsync_flag) { debug("syncing \"%s\"", local_path); if (fsync(local_fd) == -1) error("Couldn't sync file \"%s\": %s",