From b8c9684d2612663f6d98ecb3fd1ab4f98ad6ebae Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 25 Sep 2024 09:53:17 +0200 Subject: [PATCH] MT#55283 json_restore_call: check `sockaddr_parse_any_str()` Check what the `sockaddr_parse_any_str()` parsing function returns and react accordingly. Fixes a defect spotted by Coverity Scan: *** CID 1599965: Error handling issues (CHECKED_RETURN) /daemon/redis.c: 2086 in json_restore_call() 2080 c->tos = i; 2081 redis_hash_get_time_t(&c->deleted, &call, "deleted"); 2082 redis_hash_get_time_t(&c->ml_deleted, &call, "ml_deleted"); 2083 if (!redis_hash_get_str(&id, &call, "created_from")) 2084 c->created_from = call_strdup(id.s); 2085 if (!redis_hash_get_str(&id, &call, "created_from_addr")) >>> CID 1599965: Error handling issues (CHECKED_RETURN) >>> Calling "sockaddr_parse_any_str" without checking return value (as is done elsewhere 6 out of 7 times). 2086 sockaddr_parse_any_str(&c->created_from_addr, &id); 2087 if (!redis_hash_get_int(&i, &call, "block_dtmf")) 2088 c->block_dtmf = i; 2089 if (!redis_hash_get_a64(&a64, &call, "call_flags")) 2090 c->call_flags = a64; 2091 Change-Id: I79771f9987df2e395749f05095b65e0038407e65 --- daemon/redis.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/redis.c b/daemon/redis.c index 47a25a2a4..9b4df63d3 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -2082,8 +2082,10 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) redis_hash_get_time_t(&c->ml_deleted, &call, "ml_deleted"); if (!redis_hash_get_str(&id, &call, "created_from")) c->created_from = call_strdup(id.s); - if (!redis_hash_get_str(&id, &call, "created_from_addr")) - sockaddr_parse_any_str(&c->created_from_addr, &id); + if (!redis_hash_get_str(&id, &call, "created_from_addr")) { + if (sockaddr_parse_any_str(&c->created_from_addr, &id)) + goto err8; + } if (!redis_hash_get_int(&i, &call, "block_dtmf")) c->block_dtmf = i; if (!redis_hash_get_a64(&a64, &call, "call_flags"))