iemejia commented on PR #55924:
URL: https://github.com/apache/spark/pull/55924#issuecomment-5516336556

   Thanks @LuciferYang, both addressed in 53d4aafc283.
   
   1. **Out-of-bounds offset/length in the new overloads.** 
`WkbReader.readGeometry` now validates the sub-range before `ByteBuffer.wrap`:
   
      ```java
      if (offset < 0 || length > currentWkb.length - offset) {
        throw new WkbParseException("WKB range [" + offset + ", " + ((long) 
offset + length)
          + ") is out of bounds for buffer of length " + currentWkb.length, 
offset, currentWkb);
      }
      ```
   
      The subtraction form avoids `offset + length` overflow (offset is already 
known `>= 0`). A bad range now surfaces as `WKB_PARSE_ERROR` through the 
existing `fromWkb` -> `WkbParseException` path, exactly like every other kind 
of malformed WKB, instead of leaking a raw `IndexOutOfBoundsException`. Covered 
by `testStGeomFromWKBWithOutOfBoundsRange` (negative offset, offset past the 
end, and length running past the end).
   
   2. **Corrupt first value now fails fast.** You're right that pre-zeroing + 
reusing `prevBuf` turned the old loud NPE-on-null-`previous` into a silent 
wrong-data path when `prefixLength <= 64`. `readValues`, `readGeoData` and 
`skipBinary` now guard with a shared helper, run before the grow branch so 
oversized prefixes fail cleanly too rather than via AIOOBE:
   
      ```java
      private void checkPrefixLength(int prefixLength) {
        if (prefixLength > prevLen) {
          throw new ParquetDecodingException(
              "Prefix length " + prefixLength + " is larger than the previous 
value length "
                  + prevLen + "; the DELTA_BYTE_ARRAY page is corrupt");
        }
      }
      ```
   
      Legal writers never emit this (a first-page first value always has an 
empty prefix, and PARQUET-246 only affects the first value of pages after the 
first, where `prevLen` is recovered via `setPreviousReader`), so this only 
turns the corrupt-input failure mode back from silent to loud. Covered by 
`corrupt first value with a non-zero prefix fails fast` (readBinary + 
skipBinary) and its geo variant across `GeometryType(0)`, `GeometryType(4326)` 
and `GeographyType(4326)`.
   
   `STUtilsSuite` (23) and `ParquetDeltaByteArrayEncodingSuite` (27) pass. 
PTAL, thanks!
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to