Skip to content

Commit

Permalink
UDP Sender: protect against too big messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Oct 24, 2024
1 parent d0befbb commit f950618
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/RemoteUDP/Sender/Sender.ino
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
#define TAG "JSY-UDP"

#include <Arduino.h>
#include <ESPmDNS.h>
#include <AsyncUDP.h>
#include <ESPmDNS.h>

#include <ArduinoJson.h> // https://github.com/bblanchon/ArduinoJson
#include <AsyncTCP.h> // https://github.com/mathieucarbou/AsyncTCP
Expand Down Expand Up @@ -414,6 +414,13 @@ void setup() {
uint32_t crc = crc32.calc();
memcpy(buffer + size + 5, &crc, 4);

if (packetSize <= CONFIG_TCP_MSS) {
ESP_LOGE(TAG, "Packet size too big: %d. Max is: %d", packetSize, CONFIG_TCP_MSS);
messageRate = 0;
dataRate = 0;
return;
}

// send
switch (mode) {
case Mycila::ESPConnect::Mode::AP:
Expand Down

0 comments on commit f950618

Please sign in to comment.