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

[Bug]: incorrect offset in reading APDU answer of GetVersion #6586

Closed
darosior opened this issue Mar 29, 2024 · 2 comments
Closed

[Bug]: incorrect offset in reading APDU answer of GetVersion #6586

darosior opened this issue Mar 29, 2024 · 2 comments
Labels
bug Something isn't working libraries Impacts the Libraries Stale triage In need of triage

Comments

@darosior
Copy link

Impacted Library name

No response

Impacted Library version

No response

Describe the bug

The parseGetVersionResponse function seems to be incorrectly updating the offset counter after reading the SE target id. I believe it is due to a copy paste error.

Earlier in the function the flags are parsed:

// flags. gives information about manager allowed in SE mode.
const flagsLength = data[i++];
let flags = data.slice(i, i + flagsLength);
i += flagsLength;

Later when parsing the SE target id (in case the target id corresponds to a bootloader one and it's either the new or old format but WE CAN'T know this is not documented), the offset counter is updated by the value of the length of the flags slice, not the length of the SE target id slice!

const part2Length = data[i++];
const part2 = data.slice(i, i + part2Length);
i += flagsLength;

In passing, please document your APDU protocol. This is really not a fun exercise to have to reverse-engineer it from the confusing Ledger Live codebase.

Expected behavior

I don't think this changes the behaviour but could lead to a pretty nasty bug should this function be updated in the future.

Additional context

No response

@darosior darosior added bug Something isn't working libraries Impacts the Libraries triage In need of triage labels Mar 29, 2024
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label, comment, or consider closing it.

@darosior
Copy link
Author

darosior commented May 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libraries Impacts the Libraries Stale triage In need of triage
Projects
None yet
Development

No branches or pull requests

1 participant