This is an automated email from the ASF dual-hosted git repository.
gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 99f6934166 Fix an overflow in PinotDataBuffer.readFrom (#13152)
99f6934166 is described below
commit 99f6934166633308547d37cacc634e03c723ab17
Author: Gonzalo Ortiz Jaureguizar <[email protected]>
AuthorDate: Tue Jun 18 09:49:08 2024 +0200
Fix an overflow in PinotDataBuffer.readFrom (#13152)
---
.../org/apache/pinot/segment/spi/memory/PinotDataBuffer.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java
b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java
index 0895a1782b..425f7e6b84 100644
---
a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java
+++
b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/memory/PinotDataBuffer.java
@@ -521,13 +521,15 @@ public abstract class PinotDataBuffer implements
Closeable {
* Given an array of bytes, writes the content in the specified position.
*/
public void readFrom(long offset, byte[] buffer, int srcOffset, int size) {
- assert offset <= Integer.MAX_VALUE;
- int intOffset = (int) offset;
-
+ if (offset + size > size()) {
+ throw new IndexOutOfBoundsException("Buffer overflow: offset = " +
offset + ", size = " + size
+ + ", buffer size = " + size());
+ }
if (size <= BULK_BYTES_PROCESSING_THRESHOLD) {
+ long currentOffset = offset;
int end = srcOffset + size;
for (int i = srcOffset; i < end; i++) {
- putByte(intOffset++, buffer[i]);
+ putByte(currentOffset++, buffer[i]);
}
} else {
toDirectByteBuffer(offset, size).put(buffer, srcOffset, size);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]