public int getInt() {
int b1 = buf[pos++] & 0xFF;
int b2 = buf[pos++] & 0xFF;
+ validatePos(pos);
return (b1<<8) + b2;
}
public int peekInt() {
+ validatePos(pos + 2);
int b1 = buf[pos] & 0xFF;
int b2 = buf[pos+1] & 0xFF;
return (b1<<8) + b2;
public byte getByte() {
byte res = buf[pos++];
+ validatePos(pos);
return res;
}
mb.recycle();
return;
}
+ validatePos(pos + length + 1);
mb.setBytes(buf, pos, length);
mb.getCharChunk().recycle(); // not valid anymore
pos += length;
b1 |= (buf[pos++] & 0xFF);
b1 <<=8;
b1 |= (buf[pos++] & 0xFF);
+ validatePos(pos);
return b1;
}
}
+ private void validatePos(int posToTest) {
+ if (posToTest > len + 4) {
+ // Trying to read data beyond the end of the AJP message
+ throw new ArrayIndexOutOfBoundsException(sm.getString(
+ "ajpMessage.invalidPos", Integer.valueOf(pos)));
+ }
+ }
// ------------------------------------------------------ Protected Methods
ajpmessage.read=Requested {0} bytes exceeds message available data
ajpmessage.invalid=Invalid message received with signature {0}
ajpmessage.invalidLength=Invalid message received with length {0}
+ajpMessage.invalidPos=Requested read of bytes at position [{0}] which is beyond then end of the AJP message