From 91ce1c84d81b732a103bf5b611219e38a4754cbf Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 27 Jun 2024 13:23:15 +0200 Subject: [PATCH] be sure to copy not too much data to buf --- src/datIf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 5658fde..8311987 100644 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -14,6 +14,7 @@ History: #include +#include // min/max @@ -1048,7 +1049,7 @@ char T_datif::loadRecDataFromFrame() // only use as many bytes as maximally possible char buf[sizeof(struct T_dynamicCondition)]; memset(buf, 0, sizeof(buf)); - memcpy(buf, receivedData, sizeof(struct T_dynamicCondition)); + memcpy(buf, receivedData, std::min(sizeof(receivedData), sizeof(struct T_dynamicCondition))); gpi_storeDynMachineConditions(buf); } else { gpi_storeDynMachineConditions(receivedData);