From b5cb26dc479860c62fa9d6e064f893779d27fe21 Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Tue, 18 Apr 2023 19:30:22 +0300 Subject: [PATCH] [Core] Coverity fixes * [core] coverity CID 1024482 (Dereference after null check) * [core] coverity CID 1468368 (Logically dead code) * [core] coverity CID 1468459 (Logically dead code) * [core] coverity CID 1232742 (Dereference before null check) --- src/switch_core.c | 2 +- src/switch_packetizer.c | 2 -- src/switch_rtp.c | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/switch_core.c b/src/switch_core.c index cf2343482a..4e2b70778a 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -147,7 +147,7 @@ static void check_ip(void) } else if (strcmp(hostname, runtime.hostname)) { if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) { switch_event_add_header(event, SWITCH_STACK_BOTTOM, "condition", "hostname-change"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname ? hostname : "nil"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "new-hostname", runtime.hostname); switch_event_fire(&event); } diff --git a/src/switch_packetizer.c b/src/switch_packetizer.c index 05688f8a86..626e85ba8e 100644 --- a/src/switch_packetizer.c +++ b/src/switch_packetizer.c @@ -160,8 +160,6 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_feed_extradata(switch_packetiz p += 5; left -= 5; - if (left < 0) return SWITCH_STATUS_FALSE; - //sps n_sps = *p & 0x1f; p += 1; diff --git a/src/switch_rtp.c b/src/switch_rtp.c index ad9f8eef1c..614d79bf78 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1353,7 +1353,6 @@ SWITCH_DECLARE(void) switch_srtp_err_to_txt(srtp_err_status_t stat, char **msg) else if (stat == srtp_err_status_read_fail) *msg="couldn't read data"; else if (stat == srtp_err_status_write_fail) *msg="couldn't write data"; else if (stat == srtp_err_status_parse_err) *msg="error parsing data"; - else if (stat == srtp_err_status_write_fail) *msg="couldn't read data"; else if (stat == srtp_err_status_encode_err) *msg="error encoding data"; else if (stat == srtp_err_status_semaphore_err) *msg="error while using semaphores"; else if (stat == srtp_err_status_pfkey_err) *msg="error while using pfkey "; @@ -4947,7 +4946,7 @@ SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session) } if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) { - if (rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) { + if (rtp_session->sock_input && rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) { ping_socket(rtp_session); switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE); }