FrameSetView parses percentage values from HTML frameset attributes using an 
int. 
So, large values can overflow and become zero or negative. 
For example, 4294967296% which is 2^32 is parsed as zero, causing the frame to 
receive an incorrect share of the available space.

The fix checks whether adding the next digit would exceed Integer.MAX_VALUE. If 
so, it returns Integer.MAX_VALUE. 
Values within the supported range retain their existing behavior.

The subsequent percentage calculations also needs to use long arithmetic to 
prevent overflow, when adding percentages, normalizing them to a total of 100%, 
and converting percentages into pixel sizes. 



---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - fix
 - 8393731: Integer overflow in FrameSetView.parseDigits() silently converts 
large positive values to zero

Changes: https://git.openjdk.org/jdk/pull/33623/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33623&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8393731
  Stats: 99 lines in 2 files changed: 94 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/33623.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33623/head:pull/33623

PR: https://git.openjdk.org/jdk/pull/33623

Reply via email to