Skip to content

Commit

Permalink
Message.readBytes(): Fail fast if length is too large
Browse files Browse the repository at this point in the history
Cherry pick bitcoinj@694955c
  • Loading branch information
oscarguindzberg committed Jan 3, 2019
1 parent 02df9d3 commit f8b6463
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/core/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected long readVarInt(int offset) throws ProtocolException {
}

protected byte[] readBytes(int length) throws ProtocolException {
if (length > MAX_SIZE) {
if ((length > MAX_SIZE) || (cursor + length > payload.length)) {
throw new ProtocolException("Claimed value length too large: " + length);
}
try {
Expand Down

0 comments on commit f8b6463

Please sign in to comment.