mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
coverity fixes
This commit is contained in:
parent
781c6f3227
commit
7e841130e0
6 changed files with 23 additions and 9 deletions
|
@ -191,6 +191,10 @@ lws_client_connect_3_connect(struct lws *wsi, const char *ads,
|
|||
result = NULL;
|
||||
}
|
||||
|
||||
#if defined(LWS_WITH_UNIX_SOCK)
|
||||
memset(&sau, 0, sizeof(sau));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* async dns calls back here for everybody who cares when it gets a
|
||||
* result... but if we are piggybacking, we do not want to connect
|
||||
|
@ -254,10 +258,10 @@ lws_client_connect_3_connect(struct lws *wsi, const char *ads,
|
|||
}
|
||||
|
||||
#if defined(LWS_WITH_UNIX_SOCK)
|
||||
|
||||
if (ads && *ads == '+') {
|
||||
ads++;
|
||||
memset(&wsi->sa46_peer, 0, sizeof(wsi->sa46_peer));
|
||||
memset(&sau, 0, sizeof(sau));
|
||||
af = sau.sun_family = AF_UNIX;
|
||||
strncpy(sau.sun_path, ads, sizeof(sau.sun_path));
|
||||
sau.sun_path[sizeof(sau.sun_path) - 1] = '\0';
|
||||
|
|
|
@ -39,6 +39,8 @@ _lws_routing_entry_dump(struct lws_context *cx, lws_route_t *rou)
|
|||
{
|
||||
char sa[48], fin[192], *end = &fin[sizeof(fin)];
|
||||
|
||||
fin[0] = '\0';
|
||||
|
||||
if (rou->dest.sa4.sin_family) {
|
||||
lws_sa46_write_numeric_address(&rou->dest, sa, sizeof(sa));
|
||||
lws_snprintf(fin, lws_ptr_diff_size_t(end, fin),
|
||||
|
|
|
@ -377,7 +377,6 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
|
|||
p++;
|
||||
|
||||
if (*p != '-') {
|
||||
lwsl_err("b\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
@ -385,7 +384,6 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
|
|||
p++;
|
||||
|
||||
if (p >= end) {
|
||||
lwsl_err("c\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
@ -398,10 +396,8 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
|
|||
while (q > opem && *q != '\n')
|
||||
q--;
|
||||
|
||||
if (*q != '\n') {
|
||||
lwsl_err("d\n");
|
||||
if (*q != '\n')
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* we can't write into the input buffer for mem, since it may be in RO
|
||||
* const segment
|
||||
|
@ -409,7 +405,10 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
|
|||
if (filename)
|
||||
*q = '\0';
|
||||
|
||||
*amount = (unsigned int)lws_b64_decode_string_len((char *)p, lws_ptr_diff(q, p),
|
||||
n = lws_ptr_diff(q, p);
|
||||
if (n == -1) /* coverity */
|
||||
goto bail;
|
||||
*amount = (unsigned int)lws_b64_decode_string_len((char *)p, n,
|
||||
(char *)pem, (int)(long long)len);
|
||||
*buf = (uint8_t *)pem;
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ int
|
|||
main(int argc, const char **argv)
|
||||
{
|
||||
struct lws_context_creation_info info;
|
||||
#if !defined(__COVERITY__)
|
||||
const char *p;
|
||||
#endif
|
||||
int n = 1;
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -64,8 +66,10 @@ main(int argc, const char **argv)
|
|||
info.port = CONTEXT_PORT_NO_LISTEN;
|
||||
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
|
||||
|
||||
#if !defined(__COVERITY__)
|
||||
if ((p = lws_cmdline_option(argc, argv, "-i")))
|
||||
nif = p;
|
||||
#endif
|
||||
|
||||
context = lws_create_context(&info);
|
||||
if (!context) {
|
||||
|
|
|
@ -180,13 +180,18 @@ int main(int argc, const char **argv)
|
|||
LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
|
||||
}
|
||||
|
||||
if ((p = lws_cmdline_option(argc, argv, "-p")))
|
||||
if ((p = lws_cmdline_option(argc, argv, "-p"))) {
|
||||
port = atoi(p);
|
||||
if (port > 65535 || port < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((p = lws_cmdline_option(argc, argv, "-n"))) {
|
||||
n = atoi(p);
|
||||
if (n < 1)
|
||||
n = 1;
|
||||
if (n > LWS_MAX_SMP)
|
||||
n = LWS_MAX_SMP;
|
||||
if (n < nclients)
|
||||
nclients = n;
|
||||
lwsl_notice("Start test clients: %d\n", nclients);
|
||||
|
|
|
@ -2089,7 +2089,7 @@ lws_callback_raw_sshd(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
|
||||
case LWS_CALLBACK_RAW_ADOPT:
|
||||
lwsl_info("LWS_CALLBACK_RAW_ADOPT\n");
|
||||
if (!vhd)
|
||||
if (!vhd || !pss)
|
||||
return -1;
|
||||
pss->next = vhd->live_pss_list;
|
||||
vhd->live_pss_list = pss;
|
||||
|
|
Loading…
Add table
Reference in a new issue