]> git.ipfire.org Git - thirdparty/openssh-portable.git/commit
upstream: adjust ftruncate() logic to handle servers that reorder
authordjm@openbsd.org <djm@openbsd.org>
Sun, 30 Apr 2023 22:54:22 +0000 (22:54 +0000)
committerDamien Miller <djm@mindrot.org>
Sun, 30 Apr 2023 22:56:04 +0000 (08:56 +1000)
commitaacfd6767497b8fa6d41ecdd3f8e265d1e9ef1f6
tree6f09b9824e0a2d24ef7a754d7dad46afe82a4b3b
parentc8eb3941758615c8284a48fff47872db926da63c
upstream: adjust ftruncate() logic to handle servers that reorder

requests.

sftp/scp will ftruncate the destination file after a transfer completes,
to deal with the case where a longer destination file already existed.
We tracked the highest contiguous block transferred to deal with this
case, but our naive tracking doesn't deal with servers that reorder
requests - a misfeature strictly permitted by the protocol but seldom
implemented.

Adjust the logic to ftruncate() at the highest absolute block received
when the transfer is successful. feedback deraadt@ ok markus@

prompted by https://github.com/openssh/openssh-portable/commit/9b733#commitcomment-110679778

OpenBSD-Commit-ID: 4af7fac75958ad8507b4fea58706f3ff0cfddb1b
sftp-client.c