Alexander Lamaison | 30 May 2012 16:12
Picon

Re: libssh2 master 04e79e0 sftp: Don't send attrs.permissions on read-only SSH_FXP_OPEN

On 30 May 2012 14:33,  <libssh2@...> wrote:
> - Log -----------------------------------------------------------------
> commit 04e79e0c798674a0796be8a55f63dd92e6877790
> Author: Peter Stuge <peter@...>
> Commit: Peter Stuge <peter@...>
>
>    sftp: Don't send attrs.permissions on read-only SSH_FXP_OPEN
>
>    This works around a protocol violation in the ProFTPD 1.3.4 mod_sftp
>    server, as reported by Will Cosgrove in:
>
>    http://libssh2.org/mail/libssh2-devel-archive-2012-05/0079.shtml
>
>    Based on a suggested fix by TJ Saunders in:
>
>    http://libssh2.org/mail/libssh2-devel-archive-2012-05/0104.shtml
>
> diff --git a/src/sftp.c b/src/sftp.c
> index ec9d033..bd35141 100644
> --- a/src/sftp.c
> +++ b/src/sftp.c
>  <at>  <at>  -1024,9 +1024,7  <at>  <at>  sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
>     LIBSSH2_CHANNEL *channel = sftp->channel;
>     LIBSSH2_SESSION *session = channel->session;
>     LIBSSH2_SFTP_HANDLE *fp;
> -    LIBSSH2_SFTP_ATTRIBUTES attrs = {
> -        LIBSSH2_SFTP_ATTR_PERMISSIONS, 0, 0, 0, 0, 0, 0
> -    };
> +    LIBSSH2_SFTP_ATTRIBUTES attrs;
[snip]
(Continue reading)

Peter Stuge | 30 May 2012 17:51
Picon

Re: libssh2 master 04e79e0 sftp: Don't send attrs.permissions on read-only SSH_FXP_OPEN

Alexander Lamaison wrote:
> > -    LIBSSH2_SFTP_ATTRIBUTES attrs = {
> > -        LIBSSH2_SFTP_ATTR_PERMISSIONS, 0, 0, 0, 0, 0, 0
> > -    };
> > +    LIBSSH2_SFTP_ATTRIBUTES attrs;
> [snip]
> 
> Why was the initialisation of the attributes struct removed?
> Now the struct has several uninitialised fields when it is passed
> to sftp_attr2bin.

Thanks for pointing this out! Sorry for the trouble.

I'm looking more at the code now. Besides the uninitialized problem I
think the length calculation needs more work.. Sorry. My commit is
obviously bogus so I've reverted it while looking closer at what is
really needed.

The server is clearly at fault in this instance, so in case of doubt
it would also be fine to leave the code as-is.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Gmane