mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-06 10:09:33 +02:00
client/connection: verify the message_cast result (nullptr dereference)
If the server sends a mismatching reply to a `Time` request packet, the client crashes due to nullptr dereference because it uses message_cast() but does not verify the result.
This commit is contained in:
parent
947a5d1399
commit
ae9ad7e3d2
1 changed files with 3 additions and 1 deletions
|
@ -153,8 +153,10 @@ public:
|
||||||
sendRequest(message, timeout, [handler](const boost::system::error_code& ec, std::unique_ptr<msg::BaseMessage> response) {
|
sendRequest(message, timeout, [handler](const boost::system::error_code& ec, std::unique_ptr<msg::BaseMessage> response) {
|
||||||
if (ec)
|
if (ec)
|
||||||
handler(ec, nullptr);
|
handler(ec, nullptr);
|
||||||
|
else if (auto casted_response = msg::message_cast<Message>(std::move(response)))
|
||||||
|
handler(ec, std::move(casted_response));
|
||||||
else
|
else
|
||||||
handler(ec, msg::message_cast<Message>(std::move(response)));
|
handler(boost::system::errc::make_error_code(boost::system::errc::bad_message), nullptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue