Fixes after coverity static analysis
This commit is contained in:
parent
d94b4f5b7c
commit
a1badc312e
24 changed files with 148 additions and 70 deletions
|
|
@ -528,7 +528,7 @@ restconf_accept_client(int fd,
|
|||
int retval = -1;
|
||||
restconf_socket *rsock;
|
||||
clixon_handle h;
|
||||
int s;
|
||||
int s = -1;
|
||||
struct sockaddr from = {0,};
|
||||
socklen_t len;
|
||||
char *name = NULL;
|
||||
|
|
@ -568,7 +568,7 @@ restconf_accept_client(int fd,
|
|||
clixon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
}
|
||||
if (inet_ntop(from.sa_family, addr, rsock->rs_from_addr, INET6_ADDRSTRLEN) < 0)
|
||||
if (inet_ntop(from.sa_family, addr, rsock->rs_from_addr, INET6_ADDRSTRLEN) == NULL)
|
||||
goto done;
|
||||
clixon_debug(CLIXON_DBG_RESTCONF, "type:%s from:%s, dest:%s port:%hu",
|
||||
rsock->rs_addrtype,
|
||||
|
|
@ -579,11 +579,14 @@ restconf_accept_client(int fd,
|
|||
/* Accept SSL */
|
||||
if (restconf_ssl_accept_client(h, s, rsock, NULL) < 0)
|
||||
goto done;
|
||||
s = -1;
|
||||
retval = 0;
|
||||
done:
|
||||
clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
|
||||
if (name)
|
||||
free(name);
|
||||
if (s != -1)
|
||||
close(s);
|
||||
return retval;
|
||||
} /* restconf_accept_client */
|
||||
|
||||
|
|
@ -782,6 +785,7 @@ openssl_init_socket(clixon_handle h,
|
|||
rsock->rs_ss = -1; /* Not applicable from callhome */
|
||||
if (restconf_callhome_timer(rsock, 0) < 0)
|
||||
goto done;
|
||||
rsock = NULL;
|
||||
}
|
||||
else {
|
||||
/* ss is a server socket that the clients connect to. The callback
|
||||
|
|
@ -789,9 +793,12 @@ openssl_init_socket(clixon_handle h,
|
|||
rsock->rs_ss = ss;
|
||||
if (clixon_event_reg_fd(rsock->rs_ss, restconf_accept_client, rsock, "restconf socket") < 0)
|
||||
goto done;
|
||||
rsock = NULL;
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (rsock)
|
||||
free(rsock);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ restconf_stream_data *
|
|||
restconf_stream_data_new(restconf_conn *rc,
|
||||
int32_t stream_id)
|
||||
{
|
||||
restconf_stream_data *sd;
|
||||
restconf_stream_data *sd = NULL;
|
||||
|
||||
if ((sd = malloc(sizeof(restconf_stream_data))) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "malloc");
|
||||
|
|
@ -100,23 +100,30 @@ restconf_stream_data_new(restconf_conn *rc,
|
|||
sd->sd_fd = -1;
|
||||
if ((sd->sd_inbuf = cbuf_new()) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
return NULL;
|
||||
goto done;
|
||||
}
|
||||
if ((sd->sd_indata = cbuf_new()) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
return NULL;
|
||||
goto done;
|
||||
}
|
||||
if ((sd->sd_outp_hdrs = cvec_new(0)) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "cvec_new");
|
||||
return NULL;
|
||||
goto done;
|
||||
}
|
||||
if ((sd->sd_outp_buf = cbuf_new()) == NULL){
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
return NULL;
|
||||
goto done;
|
||||
}
|
||||
sd->sd_conn = rc;
|
||||
INSQ(sd, rc->rc_streams);
|
||||
ok:
|
||||
return sd;
|
||||
done:
|
||||
if (sd){
|
||||
restconf_stream_free(sd);
|
||||
sd = NULL;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
|
||||
/*! Find restconf stream data
|
||||
|
|
@ -870,7 +877,6 @@ restconf_http2_upgrade(restconf_conn *rc)
|
|||
* @param[in] rc Restconf connection
|
||||
* @param[in] buf Input buffer
|
||||
* @param[in] n Size of input buffer
|
||||
* @param[in] n Length of data in input buffer
|
||||
* @param[out] readmore If set, read data again, do not continue processing
|
||||
* @retval 1 OK
|
||||
* @retval 0 Socket closed, quit
|
||||
|
|
@ -1015,9 +1021,9 @@ restconf_connection(int s,
|
|||
#endif /* HAVE_HTTP1 */
|
||||
#ifdef HAVE_LIBNGHTTP2
|
||||
case HTTP_2:
|
||||
if ((ret = restconf_http2_process(rc, buf, n, &readmore)) < 0)
|
||||
goto done;
|
||||
gettimeofday(&rc->rc_t, NULL); /* activity timer */
|
||||
if ((ret = restconf_http2_process(rc, buf, n, &readmore)) < 0) // XXX frees rc
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto ok;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue