FrankChen021 opened a new pull request, #19818:
URL: https://github.com/apache/druid/pull/19818

   ## What changed
   
   - Use checked arithmetic and widen operands before multiplication where 
overflow could corrupt offsets, sizes, limits, or allocations.
   - Validate serialized lengths, enum ordinals, indexes, row ranges, and 
buffer bounds before use.
   - Align loop/index types with wider limits and remove an unused narrowing 
accumulator.
   - Document nine intentional arithmetic semantics with narrow CodeQL 
suppressions.
   
   ## Why
   
   The current CodeQL snapshot reports 108 arithmetic and bounds warnings:
   
   - 51 `java/tainted-arithmetic`
   - 30 `java/integer-multiplication-cast-to-long`
   - 15 `java/comparison-with-wider-type`
   - 8 `java/implicit-cast-in-compound-assignment`
   - 3 `java/improper-validation-of-array-index`
   - 1 `java/uncontrolled-arithmetic`
   
   Of these, 98 needed concrete hardening, nine intentionally preserve Java 
wrapping/IEEE-754/hash/cardinality semantics, and one multiplication was 
already widened on current upstream.
   
   ## Impact
   
   Malformed or extreme inputs now fail at explicit validation or 
checked-arithmetic boundaries instead of wrapping into incorrect buffer 
positions, allocation sizes, dictionary identifiers, or loop bounds. Normal 
behavior and serialized formats are unchanged.
   
   ## Root cause
   
   Many calculations were performed in a narrow type before assignment to a 
wider result, or relied on downstream buffer and collection APIs to reject 
invalid values. A few expressions intentionally use Java's defined wrapping or 
floating-point semantics, which static analysis cannot infer from the 
surrounding API contract.
   
   ## Checks
   
   - 709 focused test executions passed
   - 8 tests skipped
   - A randomized MSQ test passed on its configured third retry and was 
reported as a flake
   - Processing compile and checkstyle passed
   - Focused multi-module reactors passed
   - `git diff --check`
   
   Created by GPT-5.6-Sol.
   


-- 
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