> SplashDecodeJpeg() allocates bitmap storage using stride * height as a signed > int expression. SAFE_TO_ALLOC checks an unsigned 32-bit bound, so it can > accept a mathematical product above INT_MAX. The allocation expression then > has signed overflow and undefined behavior. > > If bitmap allocation fails, the function frees splash->frames but leaves its > pointer and frameCount unchanged. The buffer-allocation failure path has the > same ownership problem. A subsequent SplashCleanup(), including cleanup after > an unsuccessful startup splash decode, can read freed frame storage and > attempt to free it again. > > An example size is width 65500, height 16000, and four bytes per pixel: the > product is 4192000000, which passes the existing unsigned size guard but > exceeds INT_MAX. > > Expected behavior: size calculation must not overflow signed arithmetic, and > failure must leave no freed frame storage reachable by cleanup. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Timofei Fedotov has updated the pull request incrementally with one additional commit since the last revision: Tighten SplashScreen allocation checks and fix PNG cleanup ------------- Changes: - all: https://git.openjdk.org/jdk/pull/33915/files - new: https://git.openjdk.org/jdk/pull/33915/files/baedc28b..56a50c03 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=33915&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33915&range=00-01 Stats: 12 lines in 3 files changed: 6 ins; 0 del; 6 mod Patch: https://git.openjdk.org/jdk/pull/33915.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33915/head:pull/33915 PR: https://git.openjdk.org/jdk/pull/33915
