Skip to content

Commit 69d50db

Browse files
jakub-uCjhedberg
authored andcommitted
shell: fix a memory corruption coverity issue
Added a condition to check if the size of the copied memory is a positive number. Fixes zephyrproject-rtos#58700 Fixes zephyrproject-rtos#58703 Signed-off-by: Jakub Rzeszutko <[email protected]>
1 parent 4b5331b commit 69d50db

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

subsys/shell/shell_log_backend.c

+3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ static bool copy_to_pbuffer(struct mpsc_pbuf_buffer *mpsc_buffer,
143143
uint8_t *src_data = (uint8_t *)msg + sizeof(struct mpsc_pbuf_hdr);
144144
size_t hdr_wlen = DIV_ROUND_UP(sizeof(struct mpsc_pbuf_hdr),
145145
sizeof(uint32_t));
146+
if (wlen <= hdr_wlen) {
147+
return false;
148+
}
146149

147150
dst->hdr.data = msg->buf.hdr.data;
148151
memcpy(dst_data, src_data, (wlen - hdr_wlen) * sizeof(uint32_t));

0 commit comments

Comments
 (0)