mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
Message: remove check against max message size in checkReadLength()
Checking against the remaining bytes in the payload should be enough. The payload can't be longer than max message size.
This commit is contained in:
parent
9b3b11fd0f
commit
b39ad1904d
1 changed files with 2 additions and 3 deletions
|
@ -32,6 +32,7 @@ import java.nio.BufferUnderflowException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import static org.bitcoinj.base.internal.Preconditions.check;
|
||||||
import static org.bitcoinj.base.internal.Preconditions.checkArgument;
|
import static org.bitcoinj.base.internal.Preconditions.checkArgument;
|
||||||
import static org.bitcoinj.base.internal.Preconditions.checkState;
|
import static org.bitcoinj.base.internal.Preconditions.checkState;
|
||||||
|
|
||||||
|
@ -164,9 +165,7 @@ public abstract class Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReadLength(int length) throws BufferUnderflowException {
|
private void checkReadLength(int length) throws BufferUnderflowException {
|
||||||
if ((length > MAX_SIZE) || length > payload.remaining()) {
|
check(length <= payload.remaining(), BufferUnderflowException::new);
|
||||||
throw new BufferUnderflowException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte[] readBytes(int length) throws BufferUnderflowException {
|
protected byte[] readBytes(int length) throws BufferUnderflowException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue