mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Avoid exceeding allocated buffers when doing MQTT proxying (#8320)
the topic length could be longer than 65 characters. similarly for the payload. Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
fcaa168d2d
commit
fe6509a0f2
@ -473,7 +473,9 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo
|
||||
if (moduleConfig.mqtt.proxy_to_client_enabled) {
|
||||
meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed();
|
||||
msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag;
|
||||
strcpy(msg->topic, topic);
|
||||
strlcpy(msg->topic, topic, sizeof(msg->topic));
|
||||
if (length > sizeof(msg->payload_variant.data.bytes))
|
||||
length = sizeof(msg->payload_variant.data.bytes);
|
||||
msg->payload_variant.data.size = length;
|
||||
memcpy(msg->payload_variant.data.bytes, payload, length);
|
||||
msg->retained = retained;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user