pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

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

Open hiSandog opened this issue 5 months ago • 0 comments

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.

hiSandog avatar Jun 21 '26 04:06 hiSandog