Skip to content

fix(row): guard timestamp conversion against overflow from corrupt data - #545

Merged
JingsongLi merged 2 commits into
apache:mainfrom
hechao-ustc:fix/row-timestamp-overflow
Jul 21, 2026
Merged

fix(row): guard timestamp conversion against overflow from corrupt data#545
JingsongLi merged 2 commits into
apache:mainfrom
hechao-ustc:fix/row-timestamp-overflow

Conversation

@hechao-ustc

Copy link
Copy Markdown
Contributor

Purpose

read_timestamp_value performs unchecked multiplication (* 1_000 / * 1_000_000) on the millis value read from .row files when converting to microsecond or nanosecond precision. A corrupt or malicious file can supply an arbitrary i64 (e.g. i64::MAX), causing a panic in debug builds or silent wrapping in release builds. This PR replaces bare arithmetic with checked_mul + checked_add, returning Error::DataInvalid on overflow.

Brief change log

  • Microsecond and Nanosecond arms of read_timestamp_value: replaced bare operators with checked_mul + checked_add + ok_or_else, returning DataInvalid with millis and nanos context on overflow

Tests

  • cargo clippy --all-targets --workspace --features fulltext,vortex -- -D warnings
  • cargo test -p paimon --all-targets --features fulltext,vortex

API and Format

Documentation

Comment thread crates/paimon/src/arrow/format/row.rs Outdated

@QuakeWang QuakeWang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi
JingsongLi merged commit 9e83dea into apache:main Jul 21, 2026
12 checks passed
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.

3 participants