You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
locate: a large --max-database-age aborts via TimeDelta::days overflow #766
locate compares the database age against --max-database-age (default 8) with TimeDelta::days(config.max_age as i64) (src/locate/mod.rs:622). chrono's TimeDelta::dayspanics when the resulting duration overflows its internal range, so a large numeric argument (which clap accepts as a usize) aborts the process inside chrono instead of being rejected or clamped.
$ printf'\0LOCATE02\0\0/foo\0'> /tmp/db.bin
$ locate -d /tmp/db.bin --max-database-age 1000000000000 foothread 'main' panicked at .../chrono-0.4.45/src/lib.rs:717:17:overflow in TimeDelta::daysnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo$?101
Root cause
src/locate/mod.rs (the age-check inside the DB reader loop):
let delta = now - modified;if delta
> TimeDelta::days(config.max_ageasi64)// <-- mod.rs:622: panics on overflow{eprintln!("{}: warning: database ‘{}’ is more than {} days old ...", ...);}
config.max_age: usize comes straight from --max-database-age. chrono's TimeDelta::days(d) panics when d days can't be represented.
Activity