Skip to content

Commit

Permalink
Merge pull request #302 from kingosticks/fix/discover-bad-mac-panic
Browse files Browse the repository at this point in the history
Don't panic when the computed MAC doesn't match the client's expected MAC
  • Loading branch information
sashahilton00 authored Mar 14, 2019
2 parents 0fcfe4f + 6a60059 commit ef28df6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions 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 Expand Up @@ -221,7 +231,6 @@ pub fn discovery(

let serve = {
let http = Http::new();
debug!("Zeroconf server listening on 0.0.0.0:{}", port);
http.serve_addr_handle(
&format!("0.0.0.0:{}", port).parse().unwrap(),
&handle,
Expand All @@ -230,6 +239,7 @@ pub fn discovery(
};

let s_port = serve.incoming_ref().local_addr().port();
debug!("Zeroconf server listening on 0.0.0.0:{}", s_port);

let server_future = {
let handle = handle.clone();
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ impl Future for Main {
if !self.shutdown {
if let Some(ref spirc) = self.spirc {
spirc.shutdown();
} else {
return Ok(Async::Ready(()));
}
self.shutdown = true;
} else {
Expand Down

0 comments on commit ef28df6

Please sign in to comment.