getGPS() fails when buffer length is set to 0 - overwrites other parts of ram
cinderblock opened this issue · 0 comments
If you use the function getGPS(uint8_t arg, char *buffer, uint8_t maxbuff)
but set maxbuff to 0
, len
will always be 255
(unless somehow strlen(p) > 255
). This results in other parts of ram being overwritten which has a high chance of breaking running code.
uint8_t len = max(maxbuff-1, strlen(p));
Code excerpt from
Adafruit_FONA/Adafruit_FONA.cpp
Line 836 in 8599223
You may ask, "If you're not storing the data to some location, why do you care?" or "Why would you ever set it to 0?". I'm specifically just using the debug outputs to get the data I care about but this doesn't change the fact that this function has the ability to easily break your code.
While we're at it, buffer
should be allowed to be nullptr
and have the same effect.
There is also an issue with using max()
here as pointed out in #39.