mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
Small cleanup
This commit is contained in:
@@ -15,16 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package net.schmizz.sshj.sftp;
|
package net.schmizz.sshj.sftp;
|
||||||
|
|
||||||
|
import net.schmizz.concurrent.Promise;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import net.schmizz.concurrent.Promise;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class PacketReader
|
public class PacketReader
|
||||||
extends Thread {
|
extends Thread {
|
||||||
|
|
||||||
@@ -57,27 +56,25 @@ public class PacketReader
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
readIntoBuffer(lenBuf, 0, lenBuf.length);
|
readIntoBuffer(lenBuf, 0, lenBuf.length);
|
||||||
|
|
||||||
return (int) (lenBuf[0] << 24 & 0xff000000L
|
final long len = (lenBuf[0] << 24 & 0xff000000L
|
||||||
| lenBuf[1] << 16 & 0x00ff0000L
|
| lenBuf[1] << 16 & 0x00ff0000L
|
||||||
| lenBuf[2] << 8 & 0x0000ff00L
|
| lenBuf[2] << 8 & 0x0000ff00L
|
||||||
| lenBuf[3] & 0x000000ffL);
|
| lenBuf[3] & 0x000000ffL);
|
||||||
|
|
||||||
|
if (len > SFTPPacket.MAX_SIZE) {
|
||||||
|
throw new IllegalStateException("Invalid packet: indicated length "+len+" too large");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SFTPPacket<Response> readPacket()
|
public SFTPPacket<Response> readPacket()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int len = getPacketLength();
|
final int len = getPacketLength();
|
||||||
if (len > SFTPPacket.MAX_SIZE) {
|
packet.clear();
|
||||||
throw new IllegalStateException("Invalid packet: indicated length "+len+" too large");
|
|
||||||
}
|
|
||||||
|
|
||||||
packet.rpos(0);
|
|
||||||
packet.wpos(0);
|
|
||||||
|
|
||||||
packet.ensureCapacity(len);
|
packet.ensureCapacity(len);
|
||||||
readIntoBuffer(packet.array(), 0, len);
|
readIntoBuffer(packet.array(), 0, len);
|
||||||
|
|
||||||
packet.wpos(len);
|
packet.wpos(len);
|
||||||
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user