Skip to content

[fix][cli] Reject overflowing byte-size values#26071

Open
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/pulsar-cleanup-20260621
Open

[fix][cli] Reject overflowing byte-size values#26071
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/pulsar-cleanup-20260621

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

Motivation

ByteUnitUtil.validateSizeString parsed the numeric part as a long, then multiplied by the selected unit using normal arithmetic. Inputs such as 9223372036854775807K could overflow during unit conversion instead of being rejected as invalid.

Modifications

  • Use Math.multiplyExact when applying byte-size unit multipliers.
  • Keep invalid size errors consistent for parse failures and overflow failures.
  • Add a regression case for a long overflow input.

Verifying this change

  • git diff --check
  • Not run: ./gradlew :pulsar-cli-utils:test --tests org.apache.pulsar.cli.converters.ByteConversionTest because this environment has no Java Runtime available.

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