sftp: fix range downloads in both SSH backends

When asking for the last N bytes of a file, and that size was larger
than the file size, it would miss the first byte due to a logic error.

The fixed range parser is now made a common function in the file now
renamed to vssh.c (from curl_path.c) - used by both backends.

Unit test 2605 verifies the parser.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19460
This commit is contained in:
Daniel Stenberg 2025-11-11 09:42:16 +01:00
parent 67ef4a34f2
commit c545e10fa7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 204 additions and 84 deletions

View file

@ -265,7 +265,7 @@ test2400 test2401 test2402 test2403 test2404 test2405 test2406 \
\
test2500 test2501 test2502 test2503 \
\
test2600 test2601 test2602 test2603 test2604 \
test2600 test2601 test2602 test2603 test2604 test2605 \
\
test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 \
test2708 test2709 test2710 test2711 test2712 test2713 test2714 test2715 \

20
tests/data/test2605 Normal file
View file

@ -0,0 +1,20 @@
<testcase>
<info>
<keywords>
unittest
sftp
</keywords>
</info>
#
# Client-side
<client>
<features>
unittest
sftp
</features>
<name>
Curl_ssh_range unit test
</name>
</client>
</testcase>

View file

@ -35,7 +35,7 @@ for ssh test
# Verify data after the test has been "shot"
<verify>
<errorcode>
36
33
</errorcode>
</verify>
</testcase>