mirror of https://github.com/google/pebble
services/voice_endpoint: Fix voice crash from invalid session setup
Signed-off-by: Joshua Jun <joshuajun@proton.me>
This commit is contained in:
parent
4051c5bb97
commit
bdd8dad951
|
|
@ -145,8 +145,17 @@ void voice_endpoint_protocol_msg_callback(CommSession *session, const uint8_t* d
|
|||
case MsgIdSessionSetup: {
|
||||
if (size >= sizeof(SessionSetupResultMsg)) {
|
||||
SessionSetupResultMsg *msg = (SessionSetupResultMsg *) data;
|
||||
|
||||
// Validate result enum value to prevent crashes from invalid values
|
||||
VoiceEndpointResult result = msg->result;
|
||||
if (result > VoiceEndpointResultFailInvalidMessage) {
|
||||
PBL_LOG(LOG_LEVEL_ERROR, "Invalid VoiceEndpointResult value: %d, treating as invalid message",
|
||||
(int)result);
|
||||
result = VoiceEndpointResultFailInvalidMessage;
|
||||
}
|
||||
|
||||
bool app_initiated = (msg->flags.app_initiated == 1);
|
||||
voice_handle_session_setup_result(msg->result, msg->session_type, app_initiated);
|
||||
voice_handle_session_setup_result(result, msg->session_type, app_initiated);
|
||||
} else {
|
||||
PBL_LOG(LOG_LEVEL_WARNING, "Invalid size for session setup result message");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue