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

Ledger: Fix incorrect lenght of command INS_PREFIX_HASH #6594

Merged
merged 1 commit into from Jun 19, 2020

Conversation

grydz
Copy link
Contributor

@grydz grydz commented May 27, 2020

Using version 0.16.0.0 of the monero-wallet-cli, an error appears when trying to transfer funds to more than one address on the Ledger Nano S/X:

Error: unexpected error: Wrong Device Status: 0x6701 (UNKNOWN), EXPECTED 0x9000 (SW_OK), MASK 0xffff

This is the due to an incorrect assignment of buffer_send[4] (unsigned char representing LC) line 1482 to more than 255 which results to an incorrect lenght command.

   1     1    1    1    1     1     var
+-------------------------------------------+
| CLA | INS | P1 | P2 | LC | Opt | Add data |
+-------------------------------------------+
                        ^
                len(Opt + Add data)

It's fixed by setting len to be at most 254 (262-5-3) which the maximum lenght in Add data expected.

if (len > (BUFFER_SEND_SIZE-7)) {
len = BUFFER_SEND_SIZE-7;
if (len > (BUFFER_SEND_SIZE-8)) {
len = BUFFER_SEND_SIZE-8;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be even better to use BUFFER_SEND_SIZE-offset-1 (possibly off by one, but you get the idea) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that good idea.
@grydz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

buffer_send[4] (LC) is an unsigned char, len should not
exceed 254 (255 - 1 for the option).
@grydz grydz marked this pull request as ready for review May 27, 2020 15:25
@dEBRUYNE-1
Copy link
Contributor

@grydz - Can you open an equivalent PR against master as well?

@grydz
Copy link
Contributor Author

grydz commented May 27, 2020

@grydz - Can you open an equivalent PR against master as well?

Here is the equivalent PR on master: #6597.

@dEBRUYNE-1
Copy link
Contributor

Thanks!

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.

None yet

5 participants