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

Fix serial read error checking bug #40

Merged
merged 1 commit into from
Feb 27, 2022
Merged

Conversation

daniel214
Copy link
Contributor

size_t is unsigned, so sp_blocking_read() errors are cast to a non-negative value and skip the check on line 111.

This also causes bytes_read to appear to be a very large number (much bigger than serial_read_size) which sends lots of junk to the SLIP call and eventually causes a segfault.

This can be duplicated for test by starting the M8 without an SD card inserted or by unplugging the M8 from USB after it has launched.
Old behavior: Floods of SLIP error 1 messages, then a segfault.
New behavior:

CRITICAL: Error -2 reading serial. 
2022-02-26 23:37:08.338 m8c[15120:28714504] INFO: Shutting down
2022-02-26 23:37:08.360 m8c[15120:28714504] INFO: Disconnecting M8
2022-02-26 23:37:08.360 m8c[15120:28714504] ERROR: Error sending disconnect, code -2

(program terminates)

@laamaa laamaa merged commit 1a28e51 into laamaa:main Feb 27, 2022
@laamaa
Copy link
Owner

laamaa commented Feb 27, 2022

Thank you! Merged.

laamaa added a commit that referenced this pull request May 27, 2022
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

Successfully merging this pull request may close these issues.

2 participants