From 6d3b295b1259730c342ca22c783557e9fb73391d Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Wed, 4 Mar 2020 09:20:01 -0700 Subject: [PATCH] Fix issues flag by Coverity: 288530 Dereference after null check 288529 Array compared against 0 Signed-off-by: Alan Jowett --- src/main.c | 4 ++-- src/sec-mod-auth.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index aa5c2a01..7c1c1d91 100644 --- a/src/main.c +++ b/src/main.c @@ -1144,9 +1144,9 @@ static void listen_watcher_cb (EV_P_ ev_io *w, int revents) human_addr2((const struct sockaddr *)&ws->our_addr, ws->our_addr_len, ws->our_ip_str, sizeof(ws->our_ip_str), 0); hmac_components[0].data = ws->remote_ip_str; - hmac_components[0].length = ws->remote_ip_str ? strlen(ws->remote_ip_str) : 0; + hmac_components[0].length = strlen(ws->remote_ip_str); hmac_components[1].data = ws->our_ip_str; - hmac_components[1].length = ws->our_ip_str ? strlen(ws->our_ip_str) : 0; + hmac_components[1].length = strlen(ws->our_ip_str); hmac_components[2].data = &ws->session_start_time; hmac_components[2].length = sizeof(ws->session_start_time); diff --git a/src/sec-mod-auth.c b/src/sec-mod-auth.c index a4d0a21e..a8e9113e 100644 --- a/src/sec-mod-auth.c +++ b/src/sec-mod-auth.c @@ -780,7 +780,8 @@ int handle_sec_auth_init(int cfd, sec_mod_st *sec, const SecAuthInitMsg *req, pi /* Authenticate the client parameters */ hmac_components[0].data = req->ip; - hmac_components[0].length = req->ip ? strlen(req->ip) : 0; + // req->ip is required and protobuf doesn't permit null for required parameters + hmac_components[0].length = strlen(req->ip); hmac_components[1].data = req->our_ip; hmac_components[1].length = req->our_ip ? strlen(req->our_ip) : 0; hmac_components[2].data = (void*)&req->session_start_time;