1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

coverity fixes

This commit is contained in:
Andy Green 2022-01-10 15:33:14 +00:00
parent 781c6f3227
commit 7e841130e0
6 changed files with 23 additions and 9 deletions

View file

@ -191,6 +191,10 @@ lws_client_connect_3_connect(struct lws *wsi, const char *ads,
result = NULL; 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 * 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 * 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 defined(LWS_WITH_UNIX_SOCK)
if (ads && *ads == '+') { if (ads && *ads == '+') {
ads++; ads++;
memset(&wsi->sa46_peer, 0, sizeof(wsi->sa46_peer)); memset(&wsi->sa46_peer, 0, sizeof(wsi->sa46_peer));
memset(&sau, 0, sizeof(sau));
af = sau.sun_family = AF_UNIX; af = sau.sun_family = AF_UNIX;
strncpy(sau.sun_path, ads, sizeof(sau.sun_path)); strncpy(sau.sun_path, ads, sizeof(sau.sun_path));
sau.sun_path[sizeof(sau.sun_path) - 1] = '\0'; sau.sun_path[sizeof(sau.sun_path) - 1] = '\0';

View file

@ -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)]; char sa[48], fin[192], *end = &fin[sizeof(fin)];
fin[0] = '\0';
if (rou->dest.sa4.sin_family) { if (rou->dest.sa4.sin_family) {
lws_sa46_write_numeric_address(&rou->dest, sa, sizeof(sa)); lws_sa46_write_numeric_address(&rou->dest, sa, sizeof(sa));
lws_snprintf(fin, lws_ptr_diff_size_t(end, fin), lws_snprintf(fin, lws_ptr_diff_size_t(end, fin),

View file

@ -377,7 +377,6 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
p++; p++;
if (*p != '-') { if (*p != '-') {
lwsl_err("b\n");
goto bail; goto bail;
} }
@ -385,7 +384,6 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
p++; p++;
if (p >= end) { if (p >= end) {
lwsl_err("c\n");
goto bail; 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') while (q > opem && *q != '\n')
q--; q--;
if (*q != '\n') { if (*q != '\n')
lwsl_err("d\n");
goto bail; goto bail;
}
/* we can't write into the input buffer for mem, since it may be in RO /* we can't write into the input buffer for mem, since it may be in RO
* const segment * const segment
@ -409,7 +405,10 @@ lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
if (filename) if (filename)
*q = '\0'; *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); (char *)pem, (int)(long long)len);
*buf = (uint8_t *)pem; *buf = (uint8_t *)pem;

View file

@ -52,7 +52,9 @@ int
main(int argc, const char **argv) main(int argc, const char **argv)
{ {
struct lws_context_creation_info info; struct lws_context_creation_info info;
#if !defined(__COVERITY__)
const char *p; const char *p;
#endif
int n = 1; int n = 1;
signal(SIGINT, sigint_handler); signal(SIGINT, sigint_handler);
@ -64,8 +66,10 @@ main(int argc, const char **argv)
info.port = CONTEXT_PORT_NO_LISTEN; info.port = CONTEXT_PORT_NO_LISTEN;
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
#if !defined(__COVERITY__)
if ((p = lws_cmdline_option(argc, argv, "-i"))) if ((p = lws_cmdline_option(argc, argv, "-i")))
nif = p; nif = p;
#endif
context = lws_create_context(&info); context = lws_create_context(&info);
if (!context) { if (!context) {

View file

@ -180,13 +180,18 @@ int main(int argc, const char **argv)
LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK; 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); port = atoi(p);
if (port > 65535 || port < 0)
return 1;
}
if ((p = lws_cmdline_option(argc, argv, "-n"))) { if ((p = lws_cmdline_option(argc, argv, "-n"))) {
n = atoi(p); n = atoi(p);
if (n < 1) if (n < 1)
n = 1; n = 1;
if (n > LWS_MAX_SMP)
n = LWS_MAX_SMP;
if (n < nclients) if (n < nclients)
nclients = n; nclients = n;
lwsl_notice("Start test clients: %d\n", nclients); lwsl_notice("Start test clients: %d\n", nclients);

View file

@ -2089,7 +2089,7 @@ lws_callback_raw_sshd(struct lws *wsi, enum lws_callback_reasons reason,
case LWS_CALLBACK_RAW_ADOPT: case LWS_CALLBACK_RAW_ADOPT:
lwsl_info("LWS_CALLBACK_RAW_ADOPT\n"); lwsl_info("LWS_CALLBACK_RAW_ADOPT\n");
if (!vhd) if (!vhd || !pss)
return -1; return -1;
pss->next = vhd->live_pss_list; pss->next = vhd->live_pss_list;
vhd->live_pss_list = pss; vhd->live_pss_list = pss;