You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@parquet.apache.org by "steveloughran (via GitHub)" <gi...@apache.org> on 2026/10/24 14:21:26 UTC

Re: [PR] GH-3561 Harden variants against malformed metadata. [parquet-java]

steveloughran commented on code in PR #3562:
URL: https://github.com/apache/parquet-java/pull/3562#discussion_r4367398949


##########
parquet-variant/src/main/java/org/apache/parquet/variant/Variant.java:
##########
@@ -95,29 +128,39 @@ public Variant(ByteBuffer value, ByteBuffer metadata) {
     // Pre-compute dictionary size for lazy metadata cache allocation.
     int pos = this.metadata.position();
     int metaOffsetSize = ((this.metadata.get(pos) >> 6) & 0x3) + 1;
-    if (this.metadata.remaining() > 1) {
-      Preconditions.checkArgument(
-          this.metadata.remaining() >= 1 + metaOffsetSize,
-          "variant metadata truncated: offsetSize=" + metaOffsetSize);
-      this.dictSize = VariantUtil.readUnsignedLittleEndian(this.metadata, pos + 1, metaOffsetSize);
-      long dictTableEnd = 1L + metaOffsetSize + ((long) this.dictSize + 1) * metaOffsetSize;
-      Preconditions.checkArgument(
-          dictTableEnd <= this.metadata.remaining(),
-          "variant metadata dictionary extends past buffer: dictSize=" + this.dictSize);
-    } else {
-      this.dictSize = 0;
-    }
+    Preconditions.checkArgument(
+        this.metadata.remaining() >= 1 + metaOffsetSize,

Review Comment:
   ok. that was never a valid data structure in a file, but you think [it may have been something which code (such as test code) may have used}?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org