I was modifying the source code on a fork for my custom MQTT topic structure and noticed MQTT_MAX_TOPIC_LEN is not used in all places the associated variables mqttDeviceTopic and mqttGroupTopic are used.
When increasing this defined variable, buffer overflows will occur when trying to generate topics to publish on in mqtt.cpp and button.cpp. I personally organize all MQTT devices in a <building>/<room>/<device> topic structure, and this could potentially be more than the current 32 max topic length.
Currently, when trying to increase this variable, the following things need to be changed:
MQTT_MAX_TOPIC_LEN
lots of buffer allocation code in mqtt.cpp and button.cpp
maxlength attribute on <input> elements in settings_sync.html
It's bug-prone to have to manually adjust the buffer sizes in both cpp files. However it might be nice to have to also automatically populate the maxlength attribute on the <input> element. Not sure if this easy though.
Not applicable headers removed.
What version of WLED?
0.15.0-b7
Anything else?
~If no one else is one this after a while I'll try to submit a PR myself. Bare with me if I do that, because I've never contributed to open source before!~
I'm submitting a PR for the fix.
Code of Conduct
[x] I agree to follow this project's Code of Conduct
What happened?
I was modifying the source code on a fork for my custom MQTT topic structure and noticed
MQTT_MAX_TOPIC_LEN
is not used in all places the associated variablesmqttDeviceTopic
andmqttGroupTopic
are used.When increasing this defined variable, buffer overflows will occur when trying to generate topics to publish on in
mqtt.cpp
andbutton.cpp
. I personally organize all MQTT devices in a<building>/<room>/<device>
topic structure, and this could potentially be more than the current 32 max topic length.Currently, when trying to increase this variable, the following things need to be changed:
mqtt.cpp
andbutton.cpp
maxlength
attribute on<input>
elements insettings_sync.html
It's bug-prone to have to manually adjust the buffer sizes in both cpp files. However it might be nice to have to also automatically populate the
maxlength
attribute on the<input>
element. Not sure if this easy though.Not applicable headers removed.
What version of WLED?
0.15.0-b7
Anything else?
~If no one else is one this after a while I'll try to submit a PR myself. Bare with me if I do that, because I've never contributed to open source before!~
I'm submitting a PR for the fix.
Code of Conduct