mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
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:
@@ -279,7 +279,7 @@ impl MsgId {
|
||||
/// Starts ephemeral message timer for the message if it is not started yet.
|
||||
pub(crate) async fn start_ephemeral_timer(self, context: &Context) -> anyhow::Result<()> {
|
||||
if let Timer::Enabled { duration } = self.ephemeral_timer(context).await? {
|
||||
let ephemeral_timestamp = time() + i64::from(duration);
|
||||
let ephemeral_timestamp = time().saturating_add(duration.into());
|
||||
|
||||
context
|
||||
.sql
|
||||
|
||||
Reference in New Issue
Block a user