Use saturating addition for ephemeral timers

Integer overflows crash the application by default.

On a first sight this is only a potential crash that can't be
triggered, because timestamps are stored as i64 and ephemeral timer
duration is u32.
This commit is contained in:
link2xt
2021-09-10 22:49:48 +00:00
parent 15dcd62652
commit 6f3dd7f0c2
3 changed files with 5 additions and 3 deletions

View File

@@ -1046,7 +1046,9 @@ INSERT INTO msgs
} else {
match ephemeral_timer {
EphemeralTimer::Disabled => 0,
EphemeralTimer::Enabled { duration } => rcvd_timestamp + i64::from(duration),
EphemeralTimer::Enabled { duration } => {
rcvd_timestamp.saturating_add(duration.into())
}
}
};