1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

pscp -scp: fix spurious newlines at end of filenames.

Commit d07d7d66f introduced this bug: I replaced a manually grown
string buffer with a strbuf, and failed to replicate the part where
after I'd finished appending wire data to the string I removed the
terminating \n. That string was used as the local file name, when
downloading in SCP mode using a wildcard, so you'd get lots of local
files whose names ended inconveniently in a newline character.

Fixed by terminating the loop before we push the \n on to the strbuf
in the first place.
This commit is contained in:
Simon Tatham 2019-03-21 15:23:51 +00:00
parent 674219b115
commit 1d8b48fd22

6
pscp.c
View File

@ -1380,11 +1380,13 @@ int scp_get_sink_action(struct scp_sink_action *act)
if (ch == '\n') if (ch == '\n')
bump("Protocol error: Unexpected newline"); bump("Protocol error: Unexpected newline");
action = ch; action = ch;
do { while (1) {
if (!ssh_scp_recv(&ch, 1)) if (!ssh_scp_recv(&ch, 1))
bump("Lost connection"); bump("Lost connection");
if (ch == '\n')
break;
put_byte(act->buf, ch); put_byte(act->buf, ch);
} while (ch != '\n'); }
switch (action) { switch (action) {
case '\01': /* error */ case '\01': /* error */
with_stripctrl(san, act->buf->s) with_stripctrl(san, act->buf->s)