Skip to content

Commit

Permalink
discover: do not panic on MAC mismatch. (Fixes plietar#289)
Browse files Browse the repository at this point in the history
The client's expected MAC will not match librespot's derived MAC
if the client used the wrong public key. This can happen if librespot
is restarted (and thus generated a new key) but the client is still
mistakingly using the old public key. When this happens we do not need
to panic, we can just abort the connection attempt.
  • Loading branch information
kingosticks committed Mar 13, 2019
1 parent 8978559 commit 4c1562f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion connect/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,17 @@ impl Discovery {
h.result().code().to_owned()
};

assert_eq!(&mac[..], cksum);
if mac != cksum {
warn!("Login error for user {:?}: MAC mismatch", username);
let result = json!({
"status": 102,
"spotifyError": 1,
"statusString": "ERROR-MAC"
});

let body = result.to_string();
return ::futures::finished(Response::new().with_body(body))
}

let decrypted = {
let mut data = vec![0u8; encrypted.len()];
Expand Down

0 comments on commit 4c1562f

Please sign in to comment.