Closed pakokol closed 3 years ago
@pakokol Would you want to implement this? If not, I'll implement it in a new pull request.
@brentru sorry for the late response I didn't got any notification that you answered here on github maybe I have accidentally turned off the notifications. I suppose I could implement this if you prefer me to do it.
@pakokol No problem, still up for it?
@brentru sure why not. Just tell me how is the policity in fixing bugs. It is my first time to collaborate in a project on github :)
I edited MAXBUFFERSIZE to increase it to 1000.
Adafruit - A nice way to implement this might be:
#if !defined(MAXBUFFERSIZE)
#define MAXBUFFERSIZE 150
#endif
That would leave things as they are, but allow a user to change the buffer in their own code without editing the header file.
@brentru and @pakokol : Please take a look at https://github.com/adafruit/Adafruit_MQTT_Library/pull/166 and see if that addresses your issue.
I have an issue that might be related? If I publish an outgoing (client to adafruit.io) mqtt message that is >128 characters, it sends ok (as does follow-on outgoing messages). However the next incoming subscriber message causes coredump. My array is 256 characters, fyi. I am seeing coredumps after a certain amount of time with this, which I think is related.
127 character message is fine.
Note the length of the topic seems not relevant in my case.
I have an issue that might be related? If I publish an outgoing (client to adafruit.io) mqtt message that is >128 characters, it sends ok (as does follow-on outgoing messages). However the next incoming subscriber message causes coredump. My array is 256 characters, fyi. I am seeing coredumps after a certain amount of time with this, which I think is related.
127 character message is fine.
Note the length of the topic seems not relevant in my case.
Yes, that sounds extremely familiar. Try using my fix to see if it helps with the crash. The packet will be truncated to the max length, but at least you should stop crashing:
https://github.com/adafruit/Adafruit_MQTT_Library/pull/166
Best,
-- flaviof
Thanks!
I took the dead simple approach in my outgoing mqtt publish function and implemented this to "fix" it:
strncpy (messageToSend, messageIWantToSend, 127);
The function uint16_t Adafruit_MQTT::publishPacket has buffer overflow if you send a packet that is larger than the MAXBUFFERSIZE (topic len + data len).
As you can see from the code there isn't any check if we already went past the packet size and there fore we write over the boundaries.