Panic in From<Timestamp> for SystemTime #908

Closed
opened 2026-09-07 19:48:18 -05:00 by langston-barrett · 1 comment
langston-barrett commented 2026-09-07 19:48:18 -05:00 (Migrated from github.com)

This does not appear to be reachable from parsed UUIDs.

Note: This trait must not fail. The From trait is intended for perfect conversions. If the conversion can fail or is not perfect, use TryFrom.

https://doc.rust-lang.org/std/convert/trait.From.html

use std::time::SystemTime;
use uuid::Timestamp;

fn main() {
    let ts = Timestamp::from_unix_time(u64::MAX, 999_999_999, 0, 0);
    let _: SystemTime = ts.into();   // panics
}
thread 'main' (13) panicked at /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/uuid-1.26.0/src/timestamp.rs:227:9:
overflow when adding duration to `SystemTime`

Found by a fuzzer. Thanks for maintaining such a foundational crate!

This does not appear to be reachable from parsed UUIDs. > Note: This trait must not fail. The From trait is intended for perfect conversions. If the conversion can fail or is not perfect, use [TryFrom](https://doc.rust-lang.org/std/convert/trait.TryFrom.html). https://doc.rust-lang.org/std/convert/trait.From.html ```rust use std::time::SystemTime; use uuid::Timestamp; fn main() { let ts = Timestamp::from_unix_time(u64::MAX, 999_999_999, 0, 0); let _: SystemTime = ts.into(); // panics } ``` ``` thread 'main' (13) panicked at /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/uuid-1.26.0/src/timestamp.rs:227:9: overflow when adding duration to `SystemTime` ``` Found by a fuzzer. Thanks for maintaining such a foundational crate!
KodrAus commented 2026-09-09 18:36:45 -05:00 (Migrated from github.com)

Thanks for the report @langston-barrett! We should probably just saturate in the case you'd overflow

Thanks for the report @langston-barrett! We should probably just saturate in the case you'd overflow
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#908
No description provided.