/** * Read a message and guarantee that the <b>contents</b> is not larger than * <code>maxlen</code> bytes. * <p/> * Note: receiveMessage(34000) actually means that the message may be up to 34004 * bytes (the length attribute preceeding the contents is 4 bytes). * * @param maxlen * @return the message contents * @throws IOException */ private byte[] receiveMessage(int maxlen) throws IOException { byte[] msglen = new byte[4]; readBytes(msglen, 0, 4); int len = (((msglen[0] & 0xff) << 24) | ((msglen[1] & 0xff) << 16) | ((msglen[2] & 0xff) << 8) | (msglen[3] & 0xff)); if ((len > maxlen) || (len <= 0)) { throw new IOException("Illegal sftp packet len: " + len); } byte[] msg = new byte[len]; readBytes(msg, 0, len); return msg; }
/** * Read a message and guarantee that the <b>contents</b> is not larger than * <code>maxlen</code> bytes. * <p/> * Note: receiveMessage(34000) actually means that the message may be up to 34004 * bytes (the length attribute preceeding the contents is 4 bytes). * * @param maxlen * @return the message contents * @throws IOException */ private byte[] receiveMessage(int maxlen) throws IOException { byte[] msglen = new byte[4]; readBytes(msglen, 0, 4); int len = (((msglen[0] & 0xff) << 24) | ((msglen[1] & 0xff) << 16) | ((msglen[2] & 0xff) << 8) | (msglen[3] & 0xff)); if ((len > maxlen) || (len <= 0)) { throw new IOException("Illegal sftp packet len: " + len); } byte[] msg = new byte[len]; readBytes(msg, 0, len); return msg; }
/** * Read a message and guarantee that the <b>contents</b> is not larger than * <code>maxlen</code> bytes. * <p> * Note: receiveMessage(34000) actually means that the message may be up to 34004 * bytes (the length attribute preceeding the contents is 4 bytes). * * @param maxlen * @return the message contents * @throws IOException */ private final byte[] receiveMessage(int maxlen) throws IOException { byte[] msglen = new byte[4]; readBytes(msglen, 0, 4); int len = (((msglen[0] & 0xff) << 24) | ((msglen[1] & 0xff) << 16) | ((msglen[2] & 0xff) << 8) | (msglen[3] & 0xff)); if ((len > maxlen) || (len <= 0)) throw new IOException("Illegal sftp packet len: " + len); byte[] msg = new byte[len]; readBytes(msg, 0, len); return msg; }
/** * Read a message and guarantee that the <b>contents</b> is not larger than * <code>maxlen</code> bytes. * <p/> * Note: receiveMessage(34000) actually means that the message may be up to 34004 * bytes (the length attribute preceeding the contents is 4 bytes). * * @param maxlen * @return the message contents * @throws IOException */ private byte[] receiveMessage(int maxlen) throws IOException { byte[] msglen = new byte[4]; readBytes(msglen, 0, 4); int len = (((msglen[0] & 0xff) << 24) | ((msglen[1] & 0xff) << 16) | ((msglen[2] & 0xff) << 8) | (msglen[3] & 0xff)); if ((len > maxlen) || (len <= 0)) { throw new IOException("Illegal sftp packet len: " + len); } byte[] msg = new byte[len]; readBytes(msg, 0, len); return msg; }