Fix issues flag by Coverity:

288530 Dereference after null check
288529 Array compared against 0

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
This commit is contained in:
Alan Jowett
2020-03-04 09:20:01 -07:00
parent 85912c705e
commit 6d3b295b12
2 changed files with 4 additions and 3 deletions

View File

@@ -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);

View File

@@ -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;