Adafruit_Learning_System_Guides icon indicating copy to clipboard operation
Adafruit_Learning_System_Guides copied to clipboard

revisiting #1091 on Feather_ePaper_Quotes

Open TonyLHansen opened this issue 4 years ago • 2 comments

The "reopen button" is not available. Regarding #1091, which is about Feather_ePaper_Quotes, found in https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/Feather_ePaper_Quotes and as described in https://learn.adafruit.com/epaper-display-featherwing-quote-display. The "fix" that was merged previously for this changed one fixed-length buffer for a slightly larger one. Instead of fixing the problem, it just postpones it until the new buffer size overflows.

I suggest you also change the strcpy() statement a few lines after the declaration on line 93

static char buff[1024]; . . . strcpy(buff,str);

to this:

static char buff[512]; . . . if (strlen(str) >= sizeof(buff)-1) { // protect against buffer overflow strncpy(buff, str, sizeof(buff)-2); buff[sizeof(buff)-1] = '\0'; } else { strcpy(buff,str); }

That will future proof the code.

Because of the small memory on the microcontroller, I also drop the size of buff back down a bit so you don't have such a large buffer floating around that is empty most of the time.

I'll put together a PR with this fix.

TonyLHansen avatar May 25 '20 01:05 TonyLHansen