Subject: [libssh2] #166: Some servers terminate connection due to large window adjustment

[libssh2] #166: Some servers terminate connection due to large window adjustment

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Wed, 24 Mar 2010 16:54:28 -0000

#166: Some servers terminate connection due to large window adjustment
---------------------------+------------------------------------------------
 Reporter: ptjm | Owner:
     Type: defect | Status: new
 Priority: normal | Milestone:
Component: protocol | Version: 1.2.4
 Keywords: window adjust | Blocking:
Blockedby: |
---------------------------+------------------------------------------------
 I've seen this problem connecting to a few different servers. When libssh2
 sends a window adjust message, the server shuts down the connection.
 Here's an excerpt from a trace:

 [libssh2] 0.784404 Transport: Received Banner: SSH-2.0-3.2.9 SSH Secure
 Shell
 [...]
 [libssh2] 2.129966 SFTP: Asking for 102 packet
 [libssh2] 2.129983 SFTP: Asking for 101 packet
 [libssh2] 2.129997 SFTP: recv packet
 [libssh2] 2.130011 Conn: channel_read() wants 4 bytes from channel 0/0
 stream #0
 => libssh2_transport_read() raw (120 bytes)
 0000: f8 05 11 5d 9f e1 71 35 d9 20 64 de 47 c4 10 5f ...]..q5. d.G.._
 0010: 62 43 89 c2 81 04 78 59 76 d3 34 2e a0 27 f1 47 bC....xYv.4..'.G
 0020: 3b ef b1 84 0b 40 3e b3 8f ef de 2b 02 58 f8 f5 ;....@>....+.X..
 0030: 37 6e 1c ff fe ed 53 a3 c5 60 61 8a 30 65 88 e5 7n....S..`a.0e..
 0040: 48 2d 0d c6 6d 2a 91 a5 8d fa 8a d9 6c c5 02 09 H-..m*......l...
 0050: 67 22 4d d1 11 8c 80 e9 63 e0 84 fc b2 ea 26 73 g"M.....c.....&s
 0060: 69 4d 72 7c 30 0c ec d1 80 85 bf b0 41 37 b8 d7 iMr|0.......A7..
 0070: 9a 58 b8 4a 4c f3 7d b2 .X.JL.}.
 => libssh2_transport_read() plain (5 bytes)
 0000: 02 00 00 00 00 .....
 [libssh2] 2.132312 Transport: Packet type 2 received, length=5
 => libssh2_transport_read() plain (48 bytes)
 0000: 01 00 00 00 02 00 00 00 21 42 61 64 20 77 69 6e ........!Bad win
 0010: 64 6f 77 20 73 69 7a 65 20 69 6e 20 57 49 4e 44 dow size in WIND
 0020: 4f 57 5f 41 44 4a 55 53 54 2e 00 00 00 02 65 6e OW_ADJUST.....en
 [libssh2] 2.133175 Transport: Packet type 1 received, length=48
 [libssh2] 2.133190 Transport: Disconnect(2): Bad window size in
 WINDOW_ADJUST.(e
 n)
 [libssh2] 2.133206 Failure Event: -13 - socket disconnect
 [libssh2] 2.133221 Failure Event: -13 - tranport read
 [libssh2] 2.133235 Failure Event: -21 - Read part of packet
 [libssh2] 2.133248 Failure Event: -1 - Timeout waiting for status message

 I found that decreasing the window size by a factor of 10 avoids this
 problem. It's not clear to me whether this change has any performance
 impact, but, e.g., openssh gets by with a maximum adjustment size of
 128kb. What is clear to me is that with this change, libssh2 can connect
 to several servers, while without it, it can't.

 I'm attaching a diff against channel.c from 1.2.4

-- 
Ticket URL: <http://libssh2.stuge.se/ticket/166>
libssh2 <http://libssh2.stuge.se/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-03-24