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 infinite loop in CPC deserialization #86

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

puddly
Copy link
Collaborator

@puddly puddly commented Nov 5, 2024

Found in f37bde1.

Ping @tl-sl

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.68%. Comparing base (b009196) to head (434b589).
Report is 8 commits behind head on dev.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #86      +/-   ##
==========================================
+ Coverage   61.78%   65.68%   +3.90%     
==========================================
  Files          14       14              
  Lines        1748     1740       -8     
==========================================
+ Hits         1080     1143      +63     
+ Misses        668      597      -71     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@puddly puddly merged commit c27feba into NabuCasa:dev Nov 5, 2024
12 checks passed
@darkxst
Copy link
Contributor

darkxst commented Nov 5, 2024

This does not seem to be raising value error:

2024-11-06 10:50:41.545 xps1520 universal_silabs_flasher.cpc DEBUG Sending data b'\x14\x00\n\x00\xc4U\xd3\x02\x00\x04\x00\x03\x00\x00\x00\xdb\x12'
2024-11-06 10:50:41.553 xps1520 universal_silabs_flasher.cpc DEBUG Failed to parse buffer bytearray(b'\x14\r\nNo command found\n> \xc4U\xd3\x02\x04\x03\xdb\x12'): ValueError('Invalid header checksum')

First byte of the response from router cli happens to match cpc_types.FLAG. I suppose it must be echoing this back the sent command.

just for reference a normal response from router does echo command back:

universal_silabs_flasher.router DEBUG Parsing State.INFO: bytearray(b'version\r\nstack ver. [8.0.2 GA build 397]\r\n\r\n> ')

@puddly
Copy link
Collaborator Author

puddly commented Nov 5, 2024

Hmm, that's different from what I thought the error was. Do you mean that with this patch, the infinite loop still happens?

@darkxst
Copy link
Contributor

darkxst commented Nov 6, 2024

Hmm, that's different from what I thought the error was. Do you mean that with this patch, the infinite loop still happens?

I hadnt noticed the echoed cpc bytes previously.

yes, it still hitting infinite loop in most cases. Occasionally a random log message is received that correctly triggers ValueError and .clear(). But for response to a command, it always starts with the cpc flag.

@puddly
Copy link
Collaborator Author

puddly commented Nov 6, 2024

Can you disable the local echo?

// <q SL_CLI_LOCAL_ECHO> Enable local echo
// <i> Default: 1
// <i> If enabled, what is written in the terminal will be echoed back, so the
// <i> user will see what is written.
#define SL_CLI_LOCAL_ECHO                  1

@darkxst
Copy link
Contributor

darkxst commented Nov 6, 2024

sure, I will try.

@tl-sl
Copy link
Contributor

tl-sl commented Nov 6, 2024

ok, it works with local echo disabled.

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.

4 participants