Skip to content

Update for SFTP-reAD - #18

Closed
LarsNordin-LNdata wants to merge 3 commits into
libssh2:masterfrom
LarsNordin-LNdata:master
Closed

LarsNordin-LNdata wants to merge 3 commits into
libssh2:masterfrom
LarsNordin-LNdata:master

Conversation

@LarsNordin-LNdata

Copy link
Copy Markdown
Contributor

hI,

Sorry for the revert and revert-revert, I need to write down the steps to update the source via GIT.

/Lars

The function sftp_read never return more then 2000 bytes (as it should
when I asked Daniel). I increased the MAX_SFTP_READ_SIZE to 30000 but
didn't get the same speed as a sftp read in SecureSSH. I analyzed the
code and found that a return always was dona when a chunk has been read.
I changit it to a sliding buffer and worked on all avaliable chunks. I
got an increase in speed and non of the test I have done has failed
(both local net and over Internet). Please review and test. I think
30000 is still not the optimal MAX_SFTP_READ_SIZE, my next goal is to
make an API to enable changing this value (The SecureSSH sftp_read has
more complete filled packages when comparing the network traffic)
@bagder

bagder commented Jun 12, 2015

Copy link
Copy Markdown
Member

So the two reverts can simply be ignored?

@bagder

bagder commented Jun 12, 2015

Copy link
Copy Markdown
Member

I merged the first commit and pushed it as commit d754fee (immediately after the 1.6.0 release to give it time to get tested before we ship it). Good enough you think?

@bagder bagder self-assigned this Jun 12, 2015
@LarsNordin-LNdata

Copy link
Copy Markdown
Contributor Author

On 2015-06-12 09:17, Daniel Stenberg wrote:

I merged the first commit and pushed it as commit d754fee
d754fee
(immediately after the 1.6.0 release to give it time to get tested
before we ship it). Good enough you think?

—
Reply to this email directly or view it on GitHub
#18 (comment).

Yes, it gives me time to do some testing of the BUFFER_SIZE value or if
it shuld be configurable via a new function.

Thanks!

/Lars

@LarsNordin-LNdata

Copy link
Copy Markdown
Contributor Author

On 2015-06-12 08:27, Daniel Stenberg wrote:

So the two reverts can simply be ignored?

—
Reply to this email directly or view it on GitHub
#18 (comment).

Yes!

/Lars

@bagder bagder closed this Jun 12, 2015
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jul 29, 2026
```
=================================================================
==45==ERROR: AddressSanitizer: attempting double-free on 0x7d0048c16680 in thread T0:
SCARINESS: 42 (double-free)
    #0 0x564127d3eb66 in free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:51:3
    libssh2#1 0x564127d986bc in ssh2_default_free /src/libssh2/src/session.c:74:5
    libssh2#2 0x564127dd403e in ssh2_kex_exchange /src/libssh2/src/kex.c:3735:9
    libssh2#3 0x564127df99af in ssh2_packet_add /src/libssh2/src/packet.c:1362:14
    libssh2#4 0x564127dadb59 in transport_fullpacket /src/libssh2/src/transport.c:338:14
    libssh2#5 0x564127da9b5b in ssh2_transport_read /src/libssh2/src/transport.c:869:18
    libssh2#6 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#7 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#8 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#9 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#10 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#11 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#12 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#13 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#14 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#15 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#16 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)
    libssh2#17 0x564127c0430d in _start (build-out/ssh2_client_fuzzer+0x6430d)

DEDUP_TOKEN: __interceptor_free--ssh2_default_free--ssh2_kex_exchange
0x7d0048c16680 is located 0 bytes inside of 491-byte region [0x7d0048c16680,0x7d0048c1686b)
freed by thread T0 here:
    #0 0x564127d3eb66 in free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:51:3
2026-07-26 22:58:44,277 - root - INFO - Fuzzer: ssh2_client_fuzzer. Detected bug.
2026-07-26 22:58:44,277 - root - INFO - Trying to reproduce crash using: /tmp/tmptfcvdhdx/crash-1987022631d6b7820f7f2167f23beb45bca9909b.
    libssh2#1 0x564127d986bc in ssh2_default_free /src/libssh2/src/session.c:74:5
    libssh2#2 0x564127da7bbf in ssh2_transport_read /src/libssh2/src/transport.c:678:17
    libssh2#3 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#4 0x564127de7a62 in kex_diffie_hellman_sha /src/libssh2/src/kex.c:555:14
    libssh2#5 0x564127deab58 in kex_method_diffie_hellman_group14_key_exchange /src/libssh2/src/kex.c:899:11
    libssh2#6 0x564127dea684 in kex_method_diffie_hellman_group14_sha256_key_exchange /src/libssh2/src/kex.c:927:12
    libssh2#7 0x564127dd3d0a in ssh2_kex_exchange /src/libssh2/src/kex.c:3719:23
    libssh2#8 0x564127df99af in ssh2_packet_add /src/libssh2/src/packet.c:1362:14
    libssh2#9 0x564127dadb59 in transport_fullpacket /src/libssh2/src/transport.c:338:14
    libssh2#10 0x564127da9b5b in ssh2_transport_read /src/libssh2/src/transport.c:869:18
    libssh2#11 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#12 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#13 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#14 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#15 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#16 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#17 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#18 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#19 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#20 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#21 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)

DEDUP_TOKEN: __interceptor_free--ssh2_default_free--ssh2_transport_read
previously allocated by thread T0 here:
    #0 0x564127d3ee04 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3
    libssh2#1 0x564127d9864c in ssh2_default_alloc /src/libssh2/src/session.c:67:12
    libssh2#2 0x564127da7c33 in ssh2_transport_read /src/libssh2/src/transport.c:679:26
    libssh2#3 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#4 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#5 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#6 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#7 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#8 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#9 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#10 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#11 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#12 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#13 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)

DEDUP_TOKEN: __interceptor_malloc--ssh2_default_alloc--ssh2_transport_read
SUMMARY: AddressSanitizer: double-free /src/libssh2/src/session.c:74:5 in ssh2_default_free
==45==ABORTING
```
https://github.com/libssh2/libssh2/actions/runs/30224178881/job/89851604319?pr=2398
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants