From 8272b32708011c3e4651b7fc3051e25c33ad8b06 Mon Sep 17 00:00:00 2001 From: David Leach Date: Tue, 30 Mar 2021 18:20:33 -0500 Subject: [PATCH] tests: modbus: Fix potential memory overwrite (coverity) Fixes #33816 Fixes #33811 Fixes #33793 Fixes #33797 Fixes #33796 Signed-off-by: David Leach --- tests/subsys/modbus/src/test_modbus_raw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/subsys/modbus/src/test_modbus_raw.c b/tests/subsys/modbus/src/test_modbus_raw.c index ebf3c1027a3..232c2eaebc4 100644 --- a/tests/subsys/modbus/src/test_modbus_raw.c +++ b/tests/subsys/modbus/src/test_modbus_raw.c @@ -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");