tests: modbus: Fix potential memory overwrite (coverity)

Fixes #33816
Fixes #33811
Fixes #33793
Fixes #33797
Fixes #33796

Signed-off-by: David Leach <david.leach@nxp.com>
This commit is contained in:
David Leach 2021-03-30 18:20:33 -05:00 committed by Anas Nashif
parent 3f0da93902
commit 8272b32708
1 changed files with 2 additions and 2 deletions

View File

@ -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);
@ -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");