summaryrefslogtreecommitdiff
path: root/sftp-client.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2019-01-23 08:01:46 +0000
committerDarren Tucker <dtucker@dtucker.net>2019-01-24 12:30:30 +1100
commit8976f1c4b2721c26e878151f52bdf346dfe2d54c (patch)
tree528e309cbe5944c0127a1c3fa0752fe2f9701232 /sftp-client.c
parent6249451f381755f792c6b9e2c2f80cdc699c14e2 (diff)
upstream: Sanitize scp filenames via snmprintf. To do this we move
the progressmeter formatting outside of signal handler context and have the atomicio callback called for EINTR too. bz#2434 with contributions from djm and jjelen at redhat.com, ok djm@ OpenBSD-Commit-ID: 1af61c1f70e4f3bd8ab140b9f1fa699481db57d8
Diffstat (limited to 'sftp-client.c')
-rw-r--r--sftp-client.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sftp-client.c b/sftp-client.c
index d3f80e5a0..36c4b8a4a 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.131 2019/01/16 23:23:45 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.132 2019/01/23 08:01:46 dtucker 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 *
@@ -102,7 +102,9 @@ sftpio(void *_bwlimit, size_t amount)
102{ 102{
103 struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit; 103 struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit;
104 104
105 bandwidth_limit(bwlimit, amount); 105 refresh_progress_meter();
106 if (bwlimit != NULL)
107 bandwidth_limit(bwlimit, amount);
106 return 0; 108 return 0;
107} 109}
108 110
@@ -122,8 +124,8 @@ send_msg(struct sftp_conn *conn, struct sshbuf *m)
122 iov[1].iov_base = (u_char *)sshbuf_ptr(m); 124 iov[1].iov_base = (u_char *)sshbuf_ptr(m);
123 iov[1].iov_len = sshbuf_len(m); 125 iov[1].iov_len = sshbuf_len(m);
124 126
125 if (atomiciov6(writev, conn->fd_out, iov, 2, 127 if (atomiciov6(writev, conn->fd_out, iov, 2, sftpio,
126 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_out) != 128 conn->limit_kbps > 0 ? &conn->bwlimit_out : NULL) !=
127 sshbuf_len(m) + sizeof(mlen)) 129 sshbuf_len(m) + sizeof(mlen))
128 fatal("Couldn't send packet: %s", strerror(errno)); 130 fatal("Couldn't send packet: %s", strerror(errno));
129 131
@@ -139,8 +141,8 @@ get_msg_extended(struct sftp_conn *conn, struct sshbuf *m, int initial)
139 141
140 if ((r = sshbuf_reserve(m, 4, &p)) != 0) 142 if ((r = sshbuf_reserve(m, 4, &p)) != 0)
141 fatal("%s: buffer error: %s", __func__, ssh_err(r)); 143 fatal("%s: buffer error: %s", __func__, ssh_err(r));
142 if (atomicio6(read, conn->fd_in, p, 4, 144 if (atomicio6(read, conn->fd_in, p, 4, sftpio,
143 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) != 4) { 145 conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL) != 4) {
144 if (errno == EPIPE || errno == ECONNRESET) 146 if (errno == EPIPE || errno == ECONNRESET)
145 fatal("Connection closed"); 147 fatal("Connection closed");
146 else 148 else
@@ -158,8 +160,8 @@ get_msg_extended(struct sftp_conn *conn, struct sshbuf *m, int initial)
158 160
159 if ((r = sshbuf_reserve(m, msg_len, &p)) != 0) 161 if ((r = sshbuf_reserve(m, msg_len, &p)) != 0)
160 fatal("%s: buffer error: %s", __func__, ssh_err(r)); 162 fatal("%s: buffer error: %s", __func__, ssh_err(r));
161 if (atomicio6(read, conn->fd_in, p, msg_len, 163 if (atomicio6(read, conn->fd_in, p, msg_len, sftpio,
162 conn->limit_kbps > 0 ? sftpio : NULL, &conn->bwlimit_in) 164 conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL)
163 != msg_len) { 165 != msg_len) {
164 if (errno == EPIPE) 166 if (errno == EPIPE)
165 fatal("Connection closed"); 167 fatal("Connection closed");