Subject: Re: LIBSSH2_SFTP_PACKET_MAXLEN

Re: LIBSSH2_SFTP_PACKET_MAXLEN

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 11 Nov 2011 13:02:16 +0100 (CET)

On Fri, 11 Nov 2011, Michael Harris wrote:

> When I add up the size of all the transport packets, the total comes to
> 40240 bytes. But in include/libssh2_sftp.h I see
>
> #define LIBSSH2_SFTP_PACKET_MAXLEN 40000
>
> Sure enough, if I rebuild libssh2 with the above constant set to, eg, 60000
> then it works perfectly.

Does it still even if you double the amount of files in the directory?

It seems the server has a larger maximum packet size than libssh2 and we
should probably consider upping the limit for when we consider it a problem.

> but in the case of SSH_FXP_READDIR packets I can't see how the server would
> know the maximum length.

The server is obliged to keep packets below the maximum size and in the
SSH_FXP_READDIR case the server stuffs N file names in each packet. It is not
mandated to stuff 394 file names into the same packet, it could use multiple
ones and then easily be below 34000 bytes.

> Of course I can build a patched version of libssh2 with this change, but the
> question is - is there a more valid way to determine the maximum size? Or is
> there some way we should be telling the server the maximum SFTP packet size
> we are willing to accept?

The check in question is only there to detect "unreasonable" packet sizes so
we could easily just bump the checked boundary and be fine with it. The
question is then only to which new value we should move it...

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-11-11