fredlcore / BSB-LAN

LAN/WiFi interface for Boiler-System-Bus (BSB) and Local Process Bus (LPB) and Punkt-zu-Punkt Schnittstelle (PPS) with a Siemens® controller used by Elco®, Brötje® and similar heating systems
222 stars 84 forks source link

Fixes in mqtt_handler.h #521

Closed fschaeck closed 1 year ago

fschaeck commented 1 year ago

An exception was thrown after publishing a json message in mqtt_mode 3. Apparently a buffer overlow in outBuf was responsible for the exception, since it did not happen for mqtt_mode 1 or 2, where the messages are significantly shorter. The refactored function mqtt_sendtoBroker() is not using outBuf anymore.

Also in the buffer overflow protection of function mqttcallback(...) 4 bytes were reserved for creating the acknowledgement message from the original message, but 5 bytes are needed (4 for the ACK prefix and one for the terminating nul character).

This pull request is fixing issue #520

fredlcore commented 1 year ago

Thanks a lot for reporting and fixing this bug :). Please use opening and closing curly brackets in if clauses etc. as we do in the rest of the code. Once formatting is in order, I'll merge this into master.

fredlcore commented 1 year ago

Thanks a lot!

fschaeck commented 1 year ago

Okay! I fixed the formatting for the whole file since I was at it.