mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-21 14:00:51 +03:00
sftp.c : discard and reset oversized packet in sftp_packet_read() (#269)
file : sftp.c notes : when sftp_packet_read() encounters an sftp packet which exceeds SFTP max packet size it now resets the reading state so it can continue reading. credit : Zhen-Huan HWANG
This commit is contained in:
committed by
Will Cosgrove
parent
dce4d8c742
commit
9ea7d3bced
@@ -346,10 +346,14 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
|
|||||||
sftp->partial_len = _libssh2_ntohu32(sftp->partial_size);
|
sftp->partial_len = _libssh2_ntohu32(sftp->partial_size);
|
||||||
/* make sure we don't proceed if the packet size is unreasonably
|
/* make sure we don't proceed if the packet size is unreasonably
|
||||||
large */
|
large */
|
||||||
if(sftp->partial_len > LIBSSH2_SFTP_PACKET_MAXLEN)
|
if(sftp->partial_len > LIBSSH2_SFTP_PACKET_MAXLEN) {
|
||||||
|
libssh2_channel_flush(channel);
|
||||||
|
sftp->partial_size_len = 0;
|
||||||
return _libssh2_error(session,
|
return _libssh2_error(session,
|
||||||
LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
|
LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
|
||||||
"SFTP packet too large");
|
"SFTP packet too large");
|
||||||
|
}
|
||||||
|
|
||||||
if(sftp->partial_len == 0)
|
if(sftp->partial_len == 0)
|
||||||
return _libssh2_error(session,
|
return _libssh2_error(session,
|
||||||
LIBSSH2_ERROR_ALLOC,
|
LIBSSH2_ERROR_ALLOC,
|
||||||
|
|||||||
Reference in New Issue
Block a user