This is an automated email from the ASF dual-hosted git repository.

FrankChen021 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 481e8fbc79f fix: validate numBytes in 
CompressedVSizeColumnarIntsSupplier (#20174)
481e8fbc79f is described below

commit 481e8fbc79f3b8790bb87004666c672e475a2563
Author: dfengliu <[email protected]>
AuthorDate: Fri Aug 28 21:23:23 2026 +0800

    fix: validate numBytes in CompressedVSizeColumnarIntsSupplier (#20174)
---
 .../data/CompressedVSizeColumnarIntsSupplier.java  |  6 ++++++
 .../CompressedVSizeColumnarIntsSupplierTest.java   | 24 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git 
a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java
 
b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java
index deddbd8bc2a..5063e1e2307 100644
--- 
a/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java
+++ 
b/processing/src/main/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplier.java
@@ -69,6 +69,12 @@ public class CompressedVSizeColumnarIntsSupplier implements 
WritableSupplier<Col
         sizePer == (1 << Integer.numberOfTrailingZeros(sizePer)),
         "Number of entries per chunk must be a power of 2"
     );
+    Preconditions.checkArgument(
+        numBytes >= 1 && numBytes <= Integer.BYTES,
+        "Invalid numBytes[%s] in CompressedVSizeColumnarIntsSupplier. Must be 
in range[1, %s]",
+        numBytes,
+        Integer.BYTES
+    );
 
     this.totalSize = totalSize;
     this.sizePer = sizePer;
diff --git 
a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java
 
b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java
index 0a56d27348f..cb51186c388 100644
--- 
a/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java
+++ 
b/processing/src/test/java/org/apache/druid/segment/data/CompressedVSizeColumnarIntsSupplierTest.java
@@ -243,6 +243,30 @@ public class CompressedVSizeColumnarIntsSupplierTest
     assertIndexMatchesVals();
   }
 
+  @Test
+  public void testInvalidNumBytesRejected() throws Exception
+  {
+    vals = new int[]{0, 1, 2, 3};
+    CloseableUtils.closeAndWrapExceptions(columnarInts);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    final CompressedVSizeColumnarIntsSupplier serialized = 
CompressedVSizeColumnarIntsSupplier.fromList(
+        IntArrayList.wrap(vals), Ints.max(vals), 4, byteOrder, 
compressionStrategy, closer
+    );
+    serialized.writeTo(Channels.newChannel(baos), null);
+    final byte[] bytes = baos.toByteArray();
+
+    for (byte invalidNumBytes : new byte[]{0, 5, 100, -1}) {
+      final byte[] corrupted = bytes.clone();
+      corrupted[1] = invalidNumBytes;
+      final IllegalArgumentException e = Assertions.assertThrows(
+          IllegalArgumentException.class,
+          () -> 
CompressedVSizeColumnarIntsSupplier.fromByteBuffer(ByteBuffer.wrap(corrupted), 
byteOrder, null)
+      );
+      Assertions.assertTrue(e.getMessage().contains("numBytes"), 
e.getMessage());
+    }
+  }
+
 
   // This test attempts to cause a race condition with the DirectByteBuffers, 
it's non-deterministic in causing it,
   // which sucks but I can't think of a way to deterministically cause it...


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to