Skip to content

Stack buffer overrun #6

@mindedc

Description

@mindedc

Thank you for the library, made creating a small fleet of sensors to record all sorts of data to influx very easy. I did find two relatively small issues as follows:

I had an issue with stack buffer overruns when doing repeated writes to the database (two writes ever 10 secs) and I don't completely understand why.

In the function InfluxArduino::write the variable writeBuff gets appended to over and over and after a few calls of the function it was writing past the length of the buffer, triggering the stack protection and rebooting the ESP32. I corrected it by changing the following line that defines the buffer to null it out when it's defined:

char writeBuf[512] = ""; // ¯_(ツ)_/¯

There is probably a more sexy way to fix this but this worked to keep it from crashing. I also noticed that the library was writing this buffer to serial via Serial.println. This isn't a bug per se but I commented it out to prevent an unwanted write to serial in my app. I would suggest that this would be an unexpected behaviour. Someone may be using the serial interface to communicate with an external device and then use this library to log data from the serial device, the spurious unexpected serial data could cause a headache. This looks like some leftover spot debugging.

Again, thank you for your contribution to the world!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions