Subject: libssh2_sftp_init() hangs with zlib compression turned on

libssh2_sftp_init() hangs with zlib compression turned on

From: Gebi Miguel <gebi.miguel_at_gmail.com>
Date: Sat, 11 Jan 2020 10:43:53 -0800

When building libSSH2 v1.9.0 with just

cmake .. -DENABLE_ZLIB_COMPRESSION=OFF -DCRYPTO_BACKEND=WinCNG -DENABLE_DEBUG_LOGGING=ON

the example sftp_write_nonblock.c works perfectly fine. The trouble starts when I add zlib compression. The current zlib-1.2.11 has been built with all the default settings ("cmake .."). Then I build libSSH2 with:

cmake .. -DENABLE_ZLIB_COMPRESSION=ON -DZLIB_LIBRARY=../../zlib-1.2.11/myBuild/Debug/zlibstaticd.lib -DZLIB_INCLUDE_DIR=../../zlib-1.2.11 -DCRYPTO_BACKEND=WinCNG -DENABLE_DEBUG_LOGGING=ON

Using sftp_write_nonblock.c again the function libssh2_sftp_init() never returns. I've added the line "libssh2_trace (session, ~0);" to the example just before libssh2_sftp_init() and that results in:

Fingerprint: 62 70 7B 7B FB DA 65 4C 73 07 D1 2F E0 19 89 CF 4C 3A F5 93
libssh2_sftp_init()!
[libssh2] 0.196284 SFTP: Initializing SFTP subsystem
[libssh2] 0.197269 Conn: Allocated new channel ID#0
[libssh2] 0.199265 Conn: Opening Channel - win 2097152 pack 32768
=> libssh2_transport_write plain (24 bytes)
0000: 5A 00 00 00 07 73 65 73 73 69 6F 6E 00 00 00 00 : Z....session....
0010: 00 20 00 00 00 00 80 00 : . ......
[libssh2] 0.206249 Socket: Sent 80/80 bytes at 00EB7880
=> libssh2_transport_write send() (80 bytes)
0000: 3A 86 97 55 4B 04 BD FB 1D B9 94 0C 11 1E FF AF : :..UK...........
0010: 85 30 05 25 07 9B 03 35 F9 3E 46 41 BC A7 8C 12 : .0.%...5.>FA....
0020: BA 1A E4 3B 22 C1 35 14 5C F8 F2 3E C5 A9 11 A7 : ...;".5.\..>....
0030: 58 8E FE 78 8A 10 BE 46 95 2C 79 C3 93 95 E1 85 : X..x...F.,y.....
0040: A3 0B F3 72 3F E8 89 ED DE 91 78 3F C7 CE 28 F2 : ...r?.....x?..(.
[libssh2] 0.220210 Transport: Looking for packet of type: 91
[libssh2] 0.221207 Transport: Looking for packet of type: 92
[libssh2] 0.296930 Socket: Recved 64/16384 bytes to 00EB3858+0
=> libssh2_transport_read() raw (64 bytes)
0000: A7 62 7B D8 05 C6 E2 87 FE 1F 96 DF B8 CA C8 2C : .b{............,
0010: 51 57 54 FE 1E A5 F6 3D 69 40 C8 CE 6A B7 4D AB : QWT....=i@..j.M.
0020: 2C 2A 3C 9E 9A 27 31 B6 99 33 C2 0D A5 78 4E DF : ,*<..'1..3...xN.
0030: 60 BD 2C BC A1 56 56 B4 72 20 7B 97 63 CE AA 93 : `.,..VV.r {.c...
=> libssh2_transport_read() plain (17 bytes)
0000: 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 : [...............
0010: 00 : .
[libssh2] 0.315881 Transport: Packet type 91 received, length=17
[libssh2] 0.317889 Transport: Looking for packet of type: 91
[libssh2] 0.319886 Conn: Connection Established - ID: 0/0 win: 0/2097152 pack: 32768/32768
[libssh2] 0.322879 Conn: starting request(subsystem) on channel 0/0, message=sftp
=> libssh2_transport_write plain (23 bytes)
0000: 62 00 00 00 00 00 00 00 09 73 75 62 73 79 73 74 : b........subsyst
0010: 65 6D 01 00 00 00 04 : em.....
=> libssh2_transport_write plain2 (4 bytes)
0000: 73 66 74 70 : sftp
[libssh2] 0.336827 Socket: Sent 80/80 bytes at 00EB7880
=> libssh2_transport_write send() (80 bytes)
0000: 3B 7A C2 06 CC 91 EA 2C C1 8A 01 95 B8 8F CB EE : ;z.....,........
0010: D3 11 28 D0 DD 6B 31 9B 13 99 41 AF EB 16 1C 26 : ..(..k1...A....&
0020: 45 6C 94 41 19 A4 2E 09 9D 7E 0F 0F 92 5E A3 5E : El.A.....~...^.^
0030: A5 B0 42 1C 91 6A 77 11 27 BE C9 92 3F C2 1F DA : ..B..jw.'...?...
0040: C4 9B 39 A6 76 AC 35 8F 59 C5 45 C5 83 39 9E A2 : ..9.v.5.Y.E..9..
[libssh2] 0.356774 Transport: Looking for packet of type: 99
[libssh2] 0.358769 Transport: Looking for packet of type: 100
[libssh2] 0.424455 Socket: Recved 112/16384 bytes to 00EB3858+0
=> libssh2_transport_read() raw (112 bytes)
0000: 00 08 B4 D7 D4 38 8C 3C 16 08 EA 58 50 86 49 52 : .....8.<...XP.IR
0010: 0D 68 12 3B 9A 97 D5 EC 21 9C D6 84 6F E6 AC C6 : .h.;....!...o...
0020: CF B8 79 C0 59 18 2F A7 82 5F 9E 64 5D 7C 15 B5 : ..y.Y./.._.d]|..
0030: 6C 86 70 30 D0 4E 13 15 40 75 00 49 E7 B7 10 B6 : l.p0.N.._at_u.I....
0040: E7 B1 F9 A1 DF 0C 80 F1 35 41 35 51 79 E0 CB 57 : ........5A5Qy..W
0050: AF 62 49 52 D6 B9 05 91 F7 5C 8C C1 FD 26 3B 3D : .bIR.....\...&;=
0060: 47 94 62 E4 2D A2 EA 0E 82 5C 42 42 AB C2 97 E6 : G.b.-....\BB....
=> libssh2_transport_read() plain (9 bytes)
0000: 5D 00 00 00 00 00 03 F7 C0 : ]........
[libssh2] 0.449138 Transport: Packet type 93 received, length=9
[libssh2] 0.453128 Conn: Window adjust for channel 0/0, adding 260032 bytes, new window_size=260032
=> libssh2_transport_read() plain (5 bytes)
0000: 63 00 00 00 00 : c....
[libssh2] 0.462104 Transport: Packet type 99 received, length=5
[libssh2] 0.464098 Transport: Looking for packet of type: 99
[libssh2] 0.466093 Conn: Setting channel 0/0 handle_extended_data mode to 1
[libssh2] 0.467090 SFTP: Sending FXP_INIT packet advertising version 3 support
[libssh2] 0.469085 Conn: Writing 9 bytes on channel 0/0, stream #0

This last line is always where things end. When I "break" the running process in Visual Studio I end up on line 140 in misc.c, at the call

rc = recv(sock, buffer, length, flags);

within _libssh2_recv(). My OS is Windows 10, I've tried with Visual Studio 2017 and 2010, shared and static libraries, different SFTP servers (test.rebex.net, a couple on the local network and RebexTinySftpServer.exe), the result is always the same, cannot make it beyond libssh2_sftp_init() with zlib compression turned on.

Any suggestions? Thank you very much for your time!

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2020-01-11