beremiz

Parents 213ebdbded0c
Children db17947a30fb
SVGHMI: fix websocket command unpacking for target that doesn't support missaligned int32 dereferencing
--- a/svghmi/svghmi.c Thu Jun 19 13:13:32 2025 +0200
+++ b/svghmi/svghmi.c Fri Jun 20 11:33:21 2025 +0200
@@ -459,9 +459,11 @@
{
case setval:
{
- uint32_t index = *(uint32_t*)(cursor);
+ uint32_t index; // = *(uint32_t*)(cursor);
uint8_t const *valptr = cursor + sizeof(uint32_t);
+ // unaligned access forces memcpy instead of cast
+ memcpy(&index, cursor, sizeof(uint32_t));
if(index == heartbeat_index)
was_hearbeat = 1;
@@ -536,8 +538,12 @@
case subscribe:
{
- uint32_t index = *(uint32_t*)(cursor);
- uint16_t refresh_period_ms = *(uint32_t*)(cursor + sizeof(uint32_t));
+ uint32_t index; // = *(uint32_t*)(cursor);
+ uint16_t refresh_period_ms; // = *(uint32_t*)(cursor + sizeof(uint32_t));
+
+ // unaligned access forces memcpy instead of cast
+ memcpy(&index, cursor, sizeof(uint32_t));
+ memcpy(&refresh_period_ms, cursor+sizeof(uint32_t), sizeof(uint16_t));
if(index < HMI_ITEM_COUNT)
{