Skip to content

Commit

Permalink
tests: modbus: Fix potential memory overwrite (coverity)
Browse files Browse the repository at this point in the history
  • Loading branch information
dleach02 authored and nashif committed Apr 1, 2021
1 parent 3f0da93 commit 8272b32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/subsys/modbus/src/test_modbus_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int server_raw_cb(const int iface, const struct modbus_adu *adu)
tmp_adu.unit_id = adu->unit_id;
tmp_adu.fc = adu->fc;
memcpy(tmp_adu.data, adu->data,
MIN(adu->length, CONFIG_MODBUS_BUFFER_SIZE));
MIN(adu->length, sizeof(tmp_adu.data)));

LOG_HEXDUMP_DBG(tmp_adu.data, tmp_adu.length, "resp");
k_sem_give(&received);
Expand All @@ -51,7 +51,7 @@ int client_raw_cb(const int iface, const struct modbus_adu *adu)
tmp_adu.unit_id = adu->unit_id;
tmp_adu.fc = adu->fc;
memcpy(tmp_adu.data, adu->data,
MIN(adu->length, CONFIG_MODBUS_BUFFER_SIZE));
MIN(adu->length, sizeof(tmp_adu.data)));

LOG_HEXDUMP_DBG(tmp_adu.data, tmp_adu.length, "c->s");

Expand Down

0 comments on commit 8272b32

Please sign in to comment.