Explorar el Código

Fix totalLen validation

Benjamin Harris hace 1 mes
padre
commit
7c7c9c96c5
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      ModulosDSP_101.ino

+ 6 - 0
ModulosDSP_101.ino

@@ -574,6 +574,12 @@ static void handleTcpBridgeClient(WiFiClient& client)
         writeHeader.dataLen   = (uint16_t)((dataBuffer[readIndex + 6] << 8) | dataBuffer[readIndex + 7]);
         writeHeader.address   = (uint16_t)((dataBuffer[readIndex + 8] << 8) | dataBuffer[readIndex + 9]);
 
+        if (writeHeader.totalLen != WRITE_HDR_LEN + writeHeader.dataLen) {
+          Serial.printf("TCP WRITE bad totalLen: got %u expected %u\n",
+                        writeHeader.totalLen, WRITE_HDR_LEN + writeHeader.dataLen);
+          ledErrorFlash(); client.stop(); return;
+        }
+
         // Need full payload — if not here yet, break back to receive loop
         if (receivedByteCount < (readIndex + WRITE_HDR_LEN + (int)writeHeader.dataLen)) {
           Serial.printf("TCP WRITE buffering: have %d need %d bytes\n",