mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 12:19:43 +03:00
Coverity: Fix reported errors
CID 1667651 CID 1667843
This commit is contained in:
1 parent
6b33d18735
commit
3c685a2b4d
2 files changed
+15
-6
No files matched your search
+10
-6
@@ -982,13 +982,11 @@ coap_add_data_large_internal(coap_session_t *session,
|
||||
/* May need token of length 8, so account for this */
|
||||
avail -= (pdu->actual_token.length < 8) ? 8 - pdu->actual_token.length : 0;
|
||||
|
||||
if (avail < 16 && ((ssize_t)length > avail || have_block_defined)) {
|
||||
/* bad luck, this is the smallest block size */
|
||||
coap_log_debug("not enough space, even the smallest block does not fit (2)\n");
|
||||
goto fail;
|
||||
if (avail < 16) {
|
||||
blk_size = 0;
|
||||
} else {
|
||||
blk_size = coap_flsll((long long)avail) - 4 - 1;
|
||||
}
|
||||
|
||||
blk_size = coap_flsll((long long)avail) - 4 - 1;
|
||||
if (blk_size > 6)
|
||||
blk_size = 6;
|
||||
|
||||
@@ -1019,6 +1017,12 @@ coap_add_data_large_internal(coap_session_t *session,
|
||||
}
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
|
||||
if (avail < 16 && ((ssize_t)length > avail || have_block_defined)) {
|
||||
/* bad luck, this is the smallest block size */
|
||||
coap_log_debug("not enough space, even the smallest block does not fit (2)\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
chunk = (size_t)1 << (blk_size + 4);
|
||||
if ((have_block_defined && block.num != 0) || single_request ||
|
||||
((session->block_mode & COAP_BLOCK_STLESS_BLOCK2) && session->type != COAP_SESSION_TYPE_CLIENT)) {
|
||||
|
||||
@@ -972,6 +972,11 @@ coap_add_observer(coap_resource_t *resource,
|
||||
ret += oscore_cbor_put_nil(&info_buf, &info_len);
|
||||
ret += oscore_cbor_put_nil(&info_buf, &info_len);
|
||||
}
|
||||
if (ret > sizeof(info_buffer)) {
|
||||
/* Should have been caught by assert() inoscborput_* functions */
|
||||
coap_log_warn("coap_add_observer overrun of info_buffer (%" PRIuS ")\n", ret);
|
||||
ret = sizeof(info_buffer);
|
||||
}
|
||||
oscore_info = coap_new_bin_const(info_buffer, ret);
|
||||
}
|
||||
#endif /* COAP_OSCORE_SUPPORT */
|
||||
|
||||
Reference in new issue
Block a user