[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hang in sftp_packet_read?


Hi Igor,

your patch seems to be better in line with the EOF signalling
implemented in other functions. I guess I'll adopt it.

Thanks,
--Peter

Am 16.05.16 um 08:54 schrieb Игорь Коваленко:
> Hi!
> I've also encountered the problem. But my fix is different:
> --- a/src/channels.c
> +++ b/src/channels.c
> @@ -2693,7 +2693,7 @@ int ssh_channel_read_timeout(ssh_channel channel,
>        return SSH_ERROR;
>    }
>    if (channel->remote_eof && buffer_get_rest_len(stdbuf) == 0) {
> -    return 0;
> +    return SSH_EOF;
>    }
>    len = buffer_get_rest_len(stdbuf);
>    /* Read count bytes if len is greater, everything otherwise */
> I've tried to post a question about it here but nobody answered, so I
> also don't know is it correct or not.
> 
> пт, 13 мая 2016 г. в 18:59, Peter Höller <ph@xxxxxxxxx
> <mailto:ph@xxxxxxxxx>>:
> 
>     Hi all,
> 
>     I recognised sftp.c:sftp_packet_read() to hang in case the sftp client
>     closes the channel. Version under test: 0.7.3.
> 
>     channel.remote_eof is set to 1, consequently ssh_channel_read() returns
>     0 causing the do {} while in sftp_packet_read() to loop infinitely.
> 
>     The patch below solves the problem for me. Could anyone please confirm
>     or correct me?
> 
>     Thanks a lot,
>     --Peter
> 
> 
>     --- sftp.c      2016-05-13 15:26:20.881799804 +0200
>     +++ sftp.c.fix  2016-05-13 15:28:35.028430265 +0200
>     @@ -335,5 +335,5 @@
>          // read from channel until 4 bytes have been read or an error
>     occurs
>          s=ssh_channel_read(sftp->channel, buffer+r, 4-r, 0);
>     -    if (s < 0) {
>     +    if (s <= 0) {
>            ssh_buffer_free(packet->payload);
>            SAFE_FREE(packet);
> 

References:
Hang in sftp_packet_read?Peter Höller <ph@xxxxxxxxx>
Re: Hang in sftp_packet_read?Игорь Коваленко <igor.a.kovalenko@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org