Skip to content

Commit

Permalink
fix: Wrong secret timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Jul 11, 2023
1 parent ca8739c commit 27a650e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pueue/src/daemon/network/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ async fn handle_incoming(

let start = SystemTime::now();

// Return immediately, if we got a wrong secret from the client.
// Return if we got a wrong secret from the client.
if payload_bytes != secret {
let received_secret = String::from_utf8(payload_bytes)?;
warn!("Received invalid secret: {received_secret}");

// Wait for 1 second before closing the socket, when getting a invalid secret.
// This invalidates any timing attacks.
let remaining_sleep_time = Duration::from_millis(1)
let remaining_sleep_time = Duration::from_secs(1)
- SystemTime::now()
.duration_since(start)
.context("Couldn't calculate duration. Did the system time change?")?;
Expand Down

0 comments on commit 27a650e

Please sign in to comment.