Skip to content

Commit

Permalink
CAN: check before trying to extend buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
garethpotter authored and martinjaeger committed Oct 12, 2023
1 parent eb7add3 commit 45b0506
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ static void thingset_can_report_rx_cb(const struct device *dev, struct can_frame
(struct thingset_can_rx_context *)buffer->user_data;
if (context->seq++ == frame->data[0]) {
int size = can_dlc_to_bytes(frame->dlc) - 1;
if (buffer->len + size > buffer->size) {
LOG_WRN("Discarding packetised message from 0x%X for data ID 0x%X as it is too "
"large.",
source_addr, data_id);
thingset_can_free_rx_buf(buffer);
return;
}
uint8_t *buf = net_buf_add(buffer, size);
int pos = 0;
bool finished =
Expand Down

0 comments on commit 45b0506

Please sign in to comment.