Skip to content

Commit 66a3c79

Browse files
committed
Add read limit check in MultiBuffer.get
1 parent 4f6253b commit 66a3c79

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/com/maxmind/db/MultiBuffer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public byte get() {
113113
/** {@inheritDoc} */
114114
@Override
115115
public Buffer get(byte[] dst) {
116+
if (position + dst.length > limit) {
117+
throw new IndexOutOfBoundsException(
118+
"Read exceeds limit: position=" + position
119+
+ ", length=" + dst.length
120+
+ ", limit=" + limit
121+
);
122+
}
116123
long pos = position;
117124
int offset = 0;
118125
int length = dst.length;

0 commit comments

Comments
 (0)