diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-09-09 02:16:21 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-09-09 02:16:21 -0400 |
commit | a3e9faa4792aa471523284bc1a847dbb7ca4f96d (patch) | |
tree | 82c48301d2c12c6ea327225c143506a3d1596ffb /src | |
parent | f364c8ef36c4b65071f5bd8fef44b20e59ed8b7b (diff) | |
download | lighttpd-git-a3e9faa4792aa471523284bc1a847dbb7ca4f96d.tar.gz |
[multiple] quiet coverity warnings
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 3 | ||||
-rw-r--r-- | src/chunk.c | 2 | ||||
-rw-r--r-- | src/chunk.h | 4 | ||||
-rw-r--r-- | src/gw_backend.c | 3 | ||||
-rw-r--r-- | src/http-header-glue.c | 3 | ||||
-rw-r--r-- | src/mod_cgi.c | 3 | ||||
-rw-r--r-- | src/mod_magnet_cache.c | 1 | ||||
-rw-r--r-- | src/t/test_mod_staticfile.c | 4 |
8 files changed, 22 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index 7a0e81e4..bad5f743 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -93,6 +93,9 @@ static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) char* buffer_string_prepare_copy(buffer * const b, const size_t size) { b->used = 0; + #ifdef __COVERITY__ /*(b->ptr is not NULL if b->size is not 0)*/ + force_assert(size >= b->size || b->ptr); + #endif return (size < b->size) ? b->ptr : buffer_alloc_replace(b, size); diff --git a/src/chunk.c b/src/chunk.c index 80d75a24..43ee14a1 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -373,7 +373,7 @@ static int chunkqueue_append_mem_extend_chunk(chunkqueue * const restrict cq, co void chunkqueue_append_buffer(chunkqueue * const restrict cq, buffer * const restrict mem) { chunk *c; - size_t len = mem ? buffer_clen(mem) : 0; + const size_t len = buffer_clen(mem); if (len < 1024 && chunkqueue_append_mem_extend_chunk(cq, mem->ptr, len)) { buffer_clear(mem); return; diff --git a/src/chunk.h b/src/chunk.h index 1690de99..06e22c6b 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -82,7 +82,11 @@ void chunkqueue_append_file(chunkqueue * restrict cq, const buffer * restrict fn void chunkqueue_append_file_fd(chunkqueue * restrict cq, const buffer * restrict fn, int fd, off_t offset, off_t len); /* copies "fn" */ void chunkqueue_append_mem(chunkqueue * restrict cq, const char * restrict mem, size_t len); /* copies memory */ void chunkqueue_append_mem_min(chunkqueue * restrict cq, const char * restrict mem, size_t len); /* copies memory */ + +__attribute_nonnull__ void chunkqueue_append_buffer(chunkqueue * restrict cq, buffer * restrict mem); /* may reset "mem" */ + +__attribute_nonnull__ void chunkqueue_append_chunkqueue(chunkqueue * restrict cq, chunkqueue * restrict src); __attribute_returns_nonnull__ diff --git a/src/gw_backend.c b/src/gw_backend.c index 6c324c91..73710ba7 100644 --- a/src/gw_backend.c +++ b/src/gw_backend.c @@ -425,6 +425,9 @@ static int gw_proc_sockaddr_init(gw_host * const host, gw_proc * const proc, log BUF_PTR_LEN(proc->unixsocket)); } else { + #ifdef __COVERITY__ + force_assert(host->host); /*(not NULL if !host->unixsocket)*/ + #endif /*(note: name resolution here is *blocking* if IP string not supplied)*/ if (1 != sock_addr_from_str_hints(&addr, &addrlen, host->host->ptr, 0, proc->port, errh)) { diff --git a/src/http-header-glue.c b/src/http-header-glue.c index d4f0e7fa..78421625 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -785,6 +785,9 @@ static int http_response_process_headers(request_st * const restrict r, http_res /* after the space should be a status code for us */ int status = http_header_str_to_code(s+9); if (status >= 100 && status < 1000) { + #ifdef __COVERITY__ /* Coverity false positive for tainted data */ + status = 200;/* http_header_str_to_code() validates, untaints */ + #endif r->http_status = status; opts->local_redir = 0; /*(disable; status was set)*/ i = 2; diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 7ad47b34..b232a813 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -776,6 +776,9 @@ static int cgi_create_env(request_st * const r, plugin_data * const p, handler_c if (-1 == c->file.fd && 0 != chunkqueue_open_file_chunk(cq, r->conf.errh)) return -1; + #ifdef __COVERITY__ + force_assert(-1 != c->file.fd); + #endif if (-1 == lseek(c->file.fd, 0, SEEK_SET)) { log_perror(r->conf.errh, __FILE__, __LINE__, "lseek %s", c->mem->ptr); diff --git a/src/mod_magnet_cache.c b/src/mod_magnet_cache.c index 49b6d936..cf25350a 100644 --- a/src/mod_magnet_cache.c +++ b/src/mod_magnet_cache.c @@ -74,6 +74,7 @@ static lua_State *script_cache_load_script(script * const sc, int etag_flags) } while (rd > 0 ? (off += rd) != sz : rd < 0 && errno == EINTR); if (off != sz) { /*(file truncated?)*/ if (rd >= 0) errno = EIO; + free(buf); return NULL; } diff --git a/src/t/test_mod_staticfile.c b/src/t/test_mod_staticfile.c index 58e4e968..a1429469 100644 --- a/src/t/test_mod_staticfile.c +++ b/src/t/test_mod_staticfile.c @@ -125,6 +125,10 @@ test_http_response_send_file (request_st * const r, time_t lmtime) "if-modified-since newer than st_mtime"); test_mod_staticfile_reset(r); + #ifdef __COVERITY__ /* Coverity misses that this is set a few lines above */ + force_assert(http_header_request_get(r, HTTP_HEADER_IF_MODIFIED_SINCE, + CONST_STR_LEN("If-Modified-Since"))); + #endif buffer_append_string_len( http_header_request_get(r, HTTP_HEADER_IF_MODIFIED_SINCE, CONST_STR_LEN("If-Modified-Since")), |