narrow down error condition: more data is ok, underflow is not

This commit is contained in:
Shikhar Bhushan
2010-06-17 18:55:53 +01:00
parent a3b6fde44a
commit 826660ab3f

View File

@@ -332,7 +332,7 @@ public abstract class AbstractChannel
protected void receiveInto(ChannelInputStream stream, SSHPacket buf)
throws ConnectionException, TransportException {
final int len = buf.readInt();
if (len < 0 || len > getLocalMaxPacketSize() || len != buf.available())
if (len < 0 || len > getLocalMaxPacketSize() || len < buf.available())
throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR, "Bad item length: " + len);
if (log.isTraceEnabled())
log.trace("IN #{}: {}", id, ByteArrayUtils.printHex(buf.array(), buf.rpos(), len));