Skip to content

Fix byte integer converter overflow#25901

Open
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/byte-converter-overflow-20260530
Open

Fix byte integer converter overflow#25901
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/byte-converter-overflow-20260530

Conversation

@hiSandog
Copy link
Copy Markdown
Contributor

Motivation

ByteUnitToIntegerConverter silently truncated byte sizes larger than Integer.MAX_VALUE because it cast the parsed long to int.

Modifications

Use Math.toIntExact so overflowing values are rejected as conversion errors, and split the converter tests to cover valid int-sized values separately from overflow cases.

Verifications

  • git diff --check
  • ./gradlew :pulsar-cli-utils:test --tests org.apache.pulsar.cli.converters.ByteConversionTest (could not run locally: Java Runtime not found)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant