bugfix: prevent array bounds violations due to short WS payload data

Guard against zero-length binary payloads before dereferencing data[0] or data[1]
This commit is contained in:
Frank
2026-03-01 22:30:04 +01:00
parent 7627fbd989
commit fa30c39a38

View File

@@ -87,7 +87,8 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
} else if (info->opcode == WS_BINARY) {
// first byte determines protocol. Note: since e131_packet_t is "packed", the compiler handles alignment issues
//DEBUG_PRINTF_P(PSTR("WS binary message: len %u, byte0: %u\n"), len, data[0]);
int offset = 1; // offset to skip protocol byte
constexpr int offset = 1; // offset to skip protocol byte
if (!data || len < offset+1) return; // catch invalid / single-byte payload
switch (data[0]) {
case BINARY_PROTOCOL_E131:
handleE131Packet((e131_packet_t*)&data[offset], client->remoteIP(), P_E131);