Hi,
Please find the latest report on new defect(s) introduced to sbabic/swupdate found with Coverity Scan.
17 new defect(s) introduced to sbabic/swupdate found with Coverity Scan.
21 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 17 of 17 defect(s)
** CID 340737: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 4192 in mg_file_write()
________________________________________________________________________________________________________
*** CID 340737: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 4192 in mg_file_write()
4186 fp = fopen(tmp, "wb");
4187 if (fp != NULL) {
4188 result = fwrite(buf, 1, len, fp) == len;
4189 fclose(fp);
4190 if (result) {
4191 remove(path);
>>> CID 340737: Error handling issues (CHECKED_RETURN)
>>> Calling "rename(tmp, path)" without checking return value. This library function may fail and return an error code.
4192 rename(tmp, path);
4193 } else {
4194 remove(tmp);
4195 }
4196 }
4197 return result;
** CID 340736: (CHECKED_RETURN)
/mongoose/mongoose.c: 3162 in setsockopts()
/mongoose/mongoose.c: 3154 in setsockopts()
/mongoose/mongoose.c: 3152 in setsockopts()
/mongoose/mongoose.c: 3150 in setsockopts()
/mongoose/mongoose.c: 3157 in setsockopts()
/mongoose/mongoose.c: 3163 in setsockopts()
________________________________________________________________________________________________________
*** CID 340736: (CHECKED_RETURN)
/mongoose/mongoose.c: 3162 in setsockopts()
3156 int idle = 60;
3157 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
3158 #endif
3159 #if !defined(_WIN32) && !defined(__QNX__)
3160 {
3161 int cnt = 3, intvl = 20;
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, IPPROTO_TCP, 6, &cnt, 4U)" without checking return value. This library function may fail and return an error code.
3162 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
3163 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl));
3164 }
3165 #endif
3166 #endif
3167 }
/mongoose/mongoose.c: 3154 in setsockopts()
3148 #define SOL_TCP IPPROTO_TCP
3149 #endif
3150 setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on));
3151 #if defined(TCP_QUICKACK)
3152 setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on));
3153 #endif
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, 1, 9, (char *)&on, 4U)" without checking return value. This library function may fail and return an error code.
3154 setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on));
3155 #if ESP32 || ESP8266 || defined(__linux__)
3156 int idle = 60;
3157 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
3158 #endif
3159 #if !defined(_WIN32) && !defined(__QNX__)
/mongoose/mongoose.c: 3152 in setsockopts()
3146 int on = 1;
3147 #if !defined(SOL_TCP)
3148 #define SOL_TCP IPPROTO_TCP
3149 #endif
3150 setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on));
3151 #if defined(TCP_QUICKACK)
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, 6, 12, (char *)&on, 4U)" without checking return value. This library function may fail and return an error code.
3152 setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on));
3153 #endif
3154 setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on));
3155 #if ESP32 || ESP8266 || defined(__linux__)
3156 int idle = 60;
3157 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
/mongoose/mongoose.c: 3150 in setsockopts()
3144 (void) c;
3145 #else
3146 int on = 1;
3147 #if !defined(SOL_TCP)
3148 #define SOL_TCP IPPROTO_TCP
3149 #endif
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, 6, 1, (char *)&on, 4U)" without checking return value. This library function may fail and return an error code.
3150 setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on));
3151 #if defined(TCP_QUICKACK)
3152 setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on));
3153 #endif
3154 setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on));
3155 #if ESP32 || ESP8266 || defined(__linux__)
/mongoose/mongoose.c: 3157 in setsockopts()
3151 #if defined(TCP_QUICKACK)
3152 setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on));
3153 #endif
3154 setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on));
3155 #if ESP32 || ESP8266 || defined(__linux__)
3156 int idle = 60;
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, IPPROTO_TCP, 4, &idle, 4U)" without checking return value. This library function may fail and return an error code.
3157 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
3158 #endif
3159 #if !defined(_WIN32) && !defined(__QNX__)
3160 {
3161 int cnt = 3, intvl = 20;
3162 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
/mongoose/mongoose.c: 3163 in setsockopts()
3157 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
3158 #endif
3159 #if !defined(_WIN32) && !defined(__QNX__)
3160 {
3161 int cnt = 3, intvl = 20;
3162 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
>>> CID 340736: (CHECKED_RETURN)
>>> Calling "setsockopt((SOCKET)(size_t)c->fd, IPPROTO_TCP, 5, &intvl, 4U)" without checking return value. This library function may fail and return an error code.
3163 setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl));
3164 }
3165 #endif
3166 #endif
3167 }
3168
** CID 340735: (CHECKED_RETURN)
/mongoose/mongoose.c: 4194 in mg_file_write()
/mongoose/mongoose.c: 4191 in mg_file_write()
________________________________________________________________________________________________________
*** CID 340735: (CHECKED_RETURN)
/mongoose/mongoose.c: 4194 in mg_file_write()
4188 result = fwrite(buf, 1, len, fp) == len;
4189 fclose(fp);
4190 if (result) {
4191 remove(path);
4192 rename(tmp, path);
4193 } else {
>>> CID 340735: (CHECKED_RETURN)
>>> Calling "remove(tmp)" without checking return value. This library function may fail and return an error code.
4194 remove(tmp);
4195 }
4196 }
4197 return result;
4198 }
4199
/mongoose/mongoose.c: 4191 in mg_file_write()
4185 snprintf(tmp, sizeof(tmp), "%s.%d", path, rand());
4186 fp = fopen(tmp, "wb");
4187 if (fp != NULL) {
4188 result = fwrite(buf, 1, len, fp) == len;
4189 fclose(fp);
4190 if (result) {
>>> CID 340735: (CHECKED_RETURN)
>>> Calling "remove(path)" without checking return value. This library function may fail and return an error code.
4191 remove(path);
4192 rename(tmp, path);
4193 } else {
4194 remove(tmp);
4195 }
4196 }
** CID 340734: (TAINTED_SCALAR)
/mongoose/mongoose.c: 222 in mg_dns_parse()
/mongoose/mongoose.c: 227 in mg_dns_parse()
________________________________________________________________________________________________________
*** CID 340734: (TAINTED_SCALAR)
/mongoose/mongoose.c: 222 in mg_dns_parse()
216
217 if (len < sizeof(*h)) return 0; // Too small, headers dont fit
218 if (mg_ntohs(h->num_questions) > 1) return 0; // Sanity
219 if (mg_ntohs(h->num_answers) > 10) return 0; // Sanity
220 dm->txnid = mg_ntohs(h->txnid);
221
>>> CID 340734: (TAINTED_SCALAR)
>>> Using tainted variable "mg_ntohs(h->num_questions)" as a loop boundary.
222 for (i = 0; i < mg_ntohs(h->num_questions); i++) {
223 if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
224 // LOG(LL_INFO, ("Q %zu %zu", ofs, n));
225 ofs += n;
226 }
227 for (i = 0; i < mg_ntohs(h->num_answers); i++) {
/mongoose/mongoose.c: 227 in mg_dns_parse()
221
222 for (i = 0; i < mg_ntohs(h->num_questions); i++) {
223 if ((n = mg_dns_parse_rr(buf, len, ofs, true, &rr)) == 0) return false;
224 // LOG(LL_INFO, ("Q %zu %zu", ofs, n));
225 ofs += n;
226 }
>>> CID 340734: (TAINTED_SCALAR)
>>> Using tainted variable "mg_ntohs(h->num_answers)" as a loop boundary.
227 for (i = 0; i < mg_ntohs(h->num_answers); i++) {
228 // LOG(LL_INFO, ("A -- %zu %zu %s", ofs, n, dm->name));
229 if ((n = mg_dns_parse_rr(buf, len, ofs, false, &rr)) == 0) return false;
230 mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name));
231 ofs += n;
232
** CID 340733: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 700 in p_seek()
________________________________________________________________________________________________________
*** CID 340733: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 700 in p_seek()
694 return fwrite(buf, 1, len, (FILE *) fp);
695 }
696
697 static size_t p_seek(void *fp, size_t offset) {
698 #if _FILE_OFFSET_BITS == 64 || _POSIX_C_SOURCE >= 200112L || \
699 _XOPEN_SOURCE >= 600
>>> CID 340733: Error handling issues (CHECKED_RETURN)
>>> Calling "fseeko((FILE *)fp, (off_t)offset, 0)" without checking return value. This library function may fail and return an error code.
700 fseeko((FILE *) fp, (off_t) offset, SEEK_SET);
701 #else
702 fseek((FILE *) fp, (long) offset, SEEK_SET);
703 #endif
704 return (size_t) ftell((FILE *) fp);
705 }
** CID 340732: Resource leaks (RESOURCE_LEAK)
/suricatta/server_hawkbit.c: 2096 in server_status_ipc()
________________________________________________________________________________________________________
*** CID 340732: Resource leaks (RESOURCE_LEAK)
/suricatta/server_hawkbit.c: 2096 in server_status_ipc()
2090 struct timeval tv = {
2091 .tv_sec = server_hawkbit.server_status_time,
2092 .tv_usec = 0
2093 };
2094
2095 pthread_mutex_lock(&ipc_lock);
>>> CID 340732: Resource leaks (RESOURCE_LEAK)
>>> Failing to save or free storage allocated by "swupdate_time_iso8601(&tv)" leaks it.
2096 sprintf(msg->data.procmsg.buf,
2097 "{\"server\":{\"status\":%d,\"time\":\"%s\"}}",
2098 server_hawkbit.server_status,
2099 swupdate_time_iso8601(&tv));
2100 msg->data.procmsg.len = strlen(msg->data.procmsg.buf);
2101 pthread_mutex_unlock(&ipc_lock);
** CID 340731: Insecure data handling (TAINTED_SCALAR)
/mongoose/mongoose.c: 2263 in mg_mqtt_next_topic()
________________________________________________________________________________________________________
*** CID 340731: Insecure data handling (TAINTED_SCALAR)
/mongoose/mongoose.c: 2263 in mg_mqtt_next_topic()
2257 if (pos >= msg->dgram.len) return 0;
2258
2259 topic->len = (size_t) (((unsigned) buf[0]) << 8 | buf[1]);
2260 topic->ptr = (char *) buf + 2;
2261 new_pos = pos + 2 + topic->len + (qos == NULL ? 0 : 1);
2262 if ((size_t) new_pos > msg->dgram.len) return 0;
>>> CID 340731: Insecure data handling (TAINTED_SCALAR)
>>> Using tainted variable "2UL + topic->len" as an index to pointer "buf".
2263 if (qos != NULL) *qos = buf[2 + topic->len];
2264 return new_pos;
2265 }
2266
2267 size_t mg_mqtt_next_sub(struct mg_mqtt_message *msg, struct mg_str *topic,
2268 uint8_t *qos, size_t pos) {
** CID 340730: Error handling issues (NEGATIVE_RETURNS)
/mongoose/mongoose.c: 4168 in mg_file_read()
________________________________________________________________________________________________________
*** CID 340730: Error handling issues (NEGATIVE_RETURNS)
/mongoose/mongoose.c: 4168 in mg_file_read()
4162 if ((fp = fopen(path, "rb")) != NULL) {
4163 fseek(fp, 0, SEEK_END);
4164 size = (size_t) ftell(fp);
4165 rewind(fp);
4166 data = (char *) calloc(1, size + 1);
4167 if (data != NULL) {
>>> CID 340730: Error handling issues (NEGATIVE_RETURNS)
>>> "size" is passed to a parameter that cannot be negative.
4168 if (fread(data, 1, size, fp) != size) {
4169 free(data);
4170 data = NULL;
4171 } else {
4172 data[size] = '\0';
4173 if (sizep != NULL) *sizep = size;
** CID 340729: (TAINTED_SCALAR)
________________________________________________________________________________________________________
*** CID 340729: (TAINTED_SCALAR)
/mongoose/mongoose.c: 4680 in mg_ws_cb()
4674 switch (op) {
4675 case WEBSOCKET_OP_CONTINUE:
4676 mg_call(c, MG_EV_WS_CTL, &m);
4677 break;
4678 case WEBSOCKET_OP_PING:
4679 LOG(LL_DEBUG, ("%s", "WS PONG"));
>>> CID 340729: (TAINTED_SCALAR)
>>> Passing tainted expression "msg.data_len" to "mg_ws_send", which uses it as an offset.
4680 mg_ws_send(c, s, msg.data_len, WEBSOCKET_OP_PONG);
4681 mg_call(c, MG_EV_WS_CTL, &m);
4682 break;
4683 case WEBSOCKET_OP_PONG:
4684 mg_call(c, MG_EV_WS_CTL, &m);
4685 break;
/mongoose/mongoose.c: 4711 in mg_ws_cb()
4705 len -= msg.header_len;
4706 ofs += len;
4707 c->pfn_data = (void *) ofs;
4708 // LOG(LL_INFO, ("FRAG %d [%.*s]", (int) ofs, (int) ofs, c->recv.buf));
4709 }
4710 // Remove non-fragmented frame
>>> CID 340729: (TAINTED_SCALAR)
>>> Passing tainted expression "c->recv.len" to "mg_iobuf_del", which uses it as an offset.
4711 if (final && op) mg_iobuf_del(&c->recv, ofs, len);
4712 // Last chunk of the fragmented frame
4713 if (final && !op) {
4714 m.flags = c->recv.buf[0];
4715 m.data = mg_str_n((char *) &c->recv.buf[1], (size_t) (ofs - 1));
4716 mg_call(c, MG_EV_WS_MSG, &m);
/mongoose/mongoose.c: 4680 in mg_ws_cb()
4674 switch (op) {
4675 case WEBSOCKET_OP_CONTINUE:
4676 mg_call(c, MG_EV_WS_CTL, &m);
4677 break;
4678 case WEBSOCKET_OP_PING:
4679 LOG(LL_DEBUG, ("%s", "WS PONG"));
>>> CID 340729: (TAINTED_SCALAR)
>>> Passing tainted expression "msg.data_len" to "mg_ws_send", which uses it as an offset.
4680 mg_ws_send(c, s, msg.data_len, WEBSOCKET_OP_PONG);
4681 mg_call(c, MG_EV_WS_CTL, &m);
4682 break;
4683 case WEBSOCKET_OP_PONG:
4684 mg_call(c, MG_EV_WS_CTL, &m);
4685 break;
/mongoose/mongoose.c: 4704 in mg_ws_cb()
4698 break;
4699 }
4700
4701 // Handle fragmented frames: strip header, keep in c->recv
4702 if (final == 0 || op == 0) {
4703 if (op) ofs++, len--, msg.header_len--; // First frame
>>> CID 340729: (TAINTED_SCALAR)
>>> Passing tainted expression "c->recv.len" to "mg_iobuf_del", which uses it as an offset.
4704 mg_iobuf_del(&c->recv, ofs, msg.header_len); // Strip header
4705 len -= msg.header_len;
4706 ofs += len;
4707 c->pfn_data = (void *) ofs;
4708 // LOG(LL_INFO, ("FRAG %d [%.*s]", (int) ofs, (int) ofs, c->recv.buf));
4709 }
** CID 340728: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 3279 in mg_mgr_wakeup()
________________________________________________________________________________________________________
*** CID 340728: Error handling issues (CHECKED_RETURN)
/mongoose/mongoose.c: 3279 in mg_mgr_wakeup()
3273
3274 return result;
3275 }
3276
3277 void mg_mgr_wakeup(struct mg_connection *c) {
3278 LOG(LL_INFO, ("skt: %p", c->pfn_data));
>>> CID 340728: Error handling issues (CHECKED_RETURN)
>>> Calling "send((SOCKET)(size_t)c->pfn_data, "\1", 1UL, 0)" without checking return value. This library function may fail and return an error code.
3279 send((SOCKET) (size_t) c->pfn_data, "\x01", 1, MSG_NONBLOCKING);
3280 }
3281
3282 static void pf1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
3283 if (ev == MG_EV_READ) mg_iobuf_free(&c->recv);
3284 (void) ev_data, (void) fn_data;
** CID 340727: (NULL_RETURNS)
________________________________________________________________________________________________________
*** CID 340727: (NULL_RETURNS)
/mongoose/mongoose_multipart.c: 353 in multipart_upload_handler()
347 if (s->len >= 9 && strncmp(s->ptr, "multipart", 9) == 0) {
348 /* New request - new proto data */
349 nc->label[0] = 'M';
350
351 nc->pfn = fn;
352 nc->pfn_data = calloc(1, sizeof(struct mg_http_multipart_stream));
>>> CID 340727: (NULL_RETURNS)
>>> Dereferencing a pointer that might be "NULL" "nc->pfn_data" when calling "mg_http_multipart_begin".
353 mg_http_multipart_begin(nc, hm);
354 mg_http_multipart_continue(nc);
355 return;
356 }
357 }
/mongoose/mongoose_multipart.c: 354 in multipart_upload_handler()
348 /* New request - new proto data */
349 nc->label[0] = 'M';
350
351 nc->pfn = fn;
352 nc->pfn_data = calloc(1, sizeof(struct mg_http_multipart_stream));
353 mg_http_multipart_begin(nc, hm);
>>> CID 340727: (NULL_RETURNS)
>>> Dereferencing a pointer that might be "NULL" "nc->pfn_data" when calling "mg_http_multipart_continue".
354 mg_http_multipart_continue(nc);
355 return;
356 }
357 }
** CID 340726: Null pointer dereferences (NULL_RETURNS)
/mongoose/mongoose.c: 680 in p_open()
________________________________________________________________________________________________________
*** CID 340726: Null pointer dereferences (NULL_RETURNS)
/mongoose/mongoose.c: 680 in p_open()
674 fp = (void *) _wfopen(b1, b2);
675 #else
676 fp = (void *) fopen(path, mode);
677 #endif
678 if (fp == NULL) return NULL;
679 fd = (struct mg_fd *) calloc(1, sizeof(*fd));
>>> CID 340726: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing "fd", which is known to be "NULL".
680 fd->fd = fp;
681 fd->fs = &mg_fs_posix;
682 return fd;
683 }
684
685 static void p_close(struct mg_fd *fd) {
** CID 340725: Security best practices violations (DC.WEAK_CRYPTO)
/mongoose/mongoose.c: 4230 in mg_random()
________________________________________________________________________________________________________
*** CID 340725: Security best practices violations (DC.WEAK_CRYPTO)
/mongoose/mongoose.c: 4230 in mg_random()
4224 if (fread(buf, 1, len, fp) == len) done = true;
4225 fclose(fp);
4226 }
4227 #endif
4228 // Fallback to a pseudo random gen
4229 if (!done) {
>>> CID 340725: Security best practices violations (DC.WEAK_CRYPTO)
>>> "rand" should not be used for security-related applications, because linear congruential algorithms are too easy to break.
4230 while (len--) *p++ = (unsigned char) (rand() & 255);
4231 }
4232 }
4233 #endif
4234
4235 bool mg_globmatch(const char *s1, size_t n1, const char *s2, size_t n2) {
** CID 340724: Null pointer dereferences (NULL_RETURNS)
/mongoose/mongoose_multipart.c: 347 in multipart_upload_handler()
________________________________________________________________________________________________________
*** CID 340724: Null pointer dereferences (NULL_RETURNS)
/mongoose/mongoose_multipart.c: 347 in multipart_upload_handler()
341 return;
342 }
343 }
344
345 if (hm->chunk.len >= 0 && ev == MG_EV_HTTP_CHUNK) {
346 s = mg_http_get_header(hm, "Content-Type");
>>> CID 340724: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing "s", which is known to be "NULL".
347 if (s->len >= 9 && strncmp(s->ptr, "multipart", 9) == 0) {
348 /* New request - new proto data */
349 nc->label[0] = 'M';
350
351 nc->pfn = fn;
352 nc->pfn_data = calloc(1, sizeof(struct mg_http_multipart_stream));
** CID 340723: Security best practices violations (DC.WEAK_CRYPTO)
/mongoose/mongoose.c: 4185 in mg_file_write()
________________________________________________________________________________________________________
*** CID 340723: Security best practices violations (DC.WEAK_CRYPTO)
/mongoose/mongoose.c: 4185 in mg_file_write()
4179 }
4180
4181 bool mg_file_write(const char *path, const void *buf, size_t len) {
4182 bool result = false;
4183 FILE *fp;
4184 char tmp[MG_PATH_MAX];
>>> CID 340723: Security best practices violations (DC.WEAK_CRYPTO)
>>> "rand" should not be used for security-related applications, because linear congruential algorithms are too easy to break.
4185 snprintf(tmp, sizeof(tmp), "%s.%d", path, rand());
4186 fp = fopen(tmp, "wb");
4187 if (fp != NULL) {
4188 result = fwrite(buf, 1, len, fp) == len;
4189 fclose(fp);
4190 if (result) {
** CID 340722: Control flow issues (NO_EFFECT)
/mongoose/mongoose_multipart.c: 345 in multipart_upload_handler()
________________________________________________________________________________________________________
*** CID 340722: Control flow issues (NO_EFFECT)
/mongoose/mongoose_multipart.c: 345 in multipart_upload_handler()
339 mg_call(nc, MG_EV_HTTP_MULTIPART_REQUEST_END, &mp);
340 mp_stream->state = MPS_FINISHED;
341 return;
342 }
343 }
344
>>> CID 340722: Control flow issues (NO_EFFECT)
>>> This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "hm->chunk.len >= 0UL".
345 if (hm->chunk.len >= 0 && ev == MG_EV_HTTP_CHUNK) {
346 s = mg_http_get_header(hm, "Content-Type");
347 if (s->len >= 9 && strncmp(s->ptr, "multipart", 9) == 0) {
348 /* New request - new proto data */
349 nc->label[0] = 'M';
350
** CID 340721: (OVERRUN)
/mongoose/mongoose.c: 4301 in mg_hexdump()
/mongoose/mongoose.c: 4301 in mg_hexdump()
________________________________________________________________________________________________________
*** CID 340721: (OVERRUN)
/mongoose/mongoose.c: 4301 in mg_hexdump()
4295 if (i > 0 && dlen > n)
4296 n += (size_t) snprintf(dst + n, dlen - n, " %s\n", ascii);
4297 if (dlen > n)
4298 n += (size_t) snprintf(dst + n, dlen - n, "%04x ", (int) (i + ofs));
4299 }
4300 if (dlen < n) break;
>>> CID 340721: (OVERRUN)
>>> Overrunning dynamic array "dst" at offset corresponding to index variable "n" through dereference in call to "snprintf".
4301 n += (size_t) snprintf(dst + n, dlen - n, " %02x", p[i]);
4302 ascii[idx] = (char) (p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i]);
4303 ascii[idx + 1] = '\0';
4304 }
4305 while (i++ % 16) {
4306 if (n < dlen) n += (size_t) snprintf(dst + n, dlen - n, "%s", " ");
/mongoose/mongoose.c: 4301 in mg_hexdump()
4295 if (i > 0 && dlen > n)
4296 n += (size_t) snprintf(dst + n, dlen - n, " %s\n", ascii);
4297 if (dlen > n)
4298 n += (size_t) snprintf(dst + n, dlen - n, "%04x ", (int) (i + ofs));
4299 }
4300 if (dlen < n) break;
>>> CID 340721: (OVERRUN)
>>> Overrunning dynamic array "dst" at offset corresponding to index variable "n" through dereference in call to "snprintf".
4301 n += (size_t) snprintf(dst + n, dlen - n, " %02x", p[i]);
4302 ascii[idx] = (char) (p[i] < 0x20 || p[i] > 0x7e ? '.' : p[i]);
4303 ascii[idx + 1] = '\0';
4304 }
4305 while (i++ % 16) {
4306 if (n < dlen) n += (size_t) snprintf(dst + n, dlen - n, "%s", " ");
________________________________________________________________________________________________________
To view the defects in Coverity Scan visit,
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yrffGusdB2gY411RFCZULj23zVH-2FYjULe-2FZVatHaTNOtXGWK7d76ThnungrCH2R2Ak-3DEGc2_U-2BcIo0IeFG9EIIQe7AiEg4oWkKw9GoOEX2k5mfx97s8hkRJNOiwyrjcEEzbe4O-2FG7jXnIf5F5MkyL1PsCWb44XINgJfBkW690OvPN3afsFVK9Wa8Qxs2Bk0uYAU-2F0M-2FlXLSSVpYDoR-2FIozje6-2F4Wy4FJUfH-2B3yJ1cpFfYqS7KMQMPWS8wFauLWWR2EcAD8OGgIbvOh3JpnyvUrDVxkqEHXHYUUrZZJpBL3x3QbDriA4-3D