mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-29 18:07:08 +03:00
Coverity: Fix CID 1483550, 1670422-1670425
CID 1594475 is a false positive as multiple threads cannot execute in the same code as global_lock is set.
This commit is contained in:
1 parent
b0a58b6da1
commit
008cff1d51
2 files changed
+10
-8
No files matched your search
@@ -3659,6 +3659,12 @@ coap_block_build_body_lkd(coap_binary_t *body_data, size_t length,
|
||||
if (body_data == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Check no overflow (including a 8 byte small headroom) */
|
||||
if (SIZE_MAX - length < 8 || offset > SIZE_MAX - length - 8) {
|
||||
coap_delete_binary(body_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Update saved data */
|
||||
if (offset + length <= total && body_data->length >= total) {
|
||||
memcpy(&body_data->s[offset], data, length);
|
||||
|
||||
+4
-8
@@ -700,8 +700,7 @@ coap_new_context(const coap_address_t *listen_addr) {
|
||||
c->dtls_context = coap_dtls_new_context(c);
|
||||
if (!c->dtls_context) {
|
||||
coap_log_emerg("coap_init: no DTLS context available\n");
|
||||
coap_free_context_lkd(c);
|
||||
return NULL;
|
||||
goto onerror;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,11 +722,10 @@ coap_new_context(const coap_address_t *listen_addr) {
|
||||
coap_lock_unlock(c);
|
||||
return c;
|
||||
|
||||
#if defined(COAP_EPOLL_SUPPORT) || COAP_SERVER_SUPPORT
|
||||
onerror:
|
||||
coap_lock_unlock();
|
||||
coap_free_type(COAP_CONTEXT, c);
|
||||
return NULL;
|
||||
#endif /* COAP_EPOLL_SUPPORT || COAP_SERVER_SUPPORT */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3579,8 +3577,6 @@ skip_handler:
|
||||
COAP_SEND_INC_PDU) == COAP_INVALID_MID)
|
||||
coap_log_debug("cannot send response for mid=0x%x\n", mid);
|
||||
response = NULL;
|
||||
if (query)
|
||||
coap_delete_string(query);
|
||||
goto finish;
|
||||
}
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
@@ -3643,9 +3639,9 @@ drop_it_no_debug:
|
||||
}
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
|
||||
#if COAP_Q_BLOCK_SUPPORT || COAP_THREAD_SAFE
|
||||
finish:
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT || COAP_THREAD_SAFE */
|
||||
if (query)
|
||||
coap_delete_string(query);
|
||||
coap_delete_string(uri_path);
|
||||
return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user