Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revisiting #1091 on Feather_ePaper_Quotes #1127

Open
TonyLHansen opened this issue May 25, 2020 · 2 comments
Open

revisiting #1091 on Feather_ePaper_Quotes #1127

TonyLHansen opened this issue May 25, 2020 · 2 comments

Comments

@TonyLHansen
Copy link

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.

@ladyada
Copy link
Member

ladyada commented May 25, 2020

@cogliano please look!

@TonyLHansen
Copy link
Author

Well, github isn't letting me create another fork of Adafruit_Learning_System_Guides into my home tree and I don't have permissions to create a PR directly into adafruit/Adafruit_Learning_System_Guides. (I have a pending PR from last November that hasn't been dealt with yet, for issue #915.) So I can't create a PR for this specific issue. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants