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

Update crypto_argon2.3monocypher - fixes errors and warnings that can lead to the incorrect solution #265

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

SethArchambault
Copy link
Contributor

Closes: #264

Fixes these issues, by allowing password array to autosize, and then making sure to drop the \0 character when determining the size of the string, and also reorders the crypto_argon2_inputs field designators to remove a warning.

main.cpp:83:24: error: initializer-string for char array is too long, array size is 14 but initializer has size 15 (including the null terminating character)
uint8_t password[14] = "Okay Password!";
                       ^~~~~~~~~~~~~~~~
main.cpp:87:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'pass_size' will be initialized after field 'salt' [-Wreorder-init-list]
    .salt      = salt,                 /* Salt for the password */
    ^~~~~~~~~~~~~~~~~

… lead to incorrect solution

Closes: LoupVaillant#264 

Fixes these issues, by allowing password array to autosize, and then making sure to drop the \0 character when determining the size of the string, and also reorders the crypto_argon2_inputs field designators to remove a warning.

```
main.cpp:83:24: error: initializer-string for char array is too long, array size is 14 but initializer has size 15 (including the null terminating character)
uint8_t password[14] = "Okay Password!";
                       ^~~~~~~~~~~~~~~~
main.cpp:87:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'pass_size' will be initialized after field 'salt' [-Wreorder-init-list]
    .salt      = salt,                 /* Salt for the password */
    ^~~~~~~~~~~~~~~~~
```
@LoupVaillant LoupVaillant merged commit 983e136 into LoupVaillant:master Oct 19, 2023
1 check passed
@LoupVaillant
Copy link
Owner

Looks pretty good to me, thanks for the fix!

This may help more than you realise, such issues not only waste time (sorry about yours), they also tend to hurt whatever trust users may have in the library.

@SethArchambault
Copy link
Contributor Author

@LoupVaillant Cool, glad it helps! 😄

Appreciate your work, and glad this exists! 👍

@SethArchambault SethArchambault deleted the patch-1 branch October 19, 2023 23:44
@SethArchambault
Copy link
Contributor Author

Realizing now that I was conflating strlen with sizeof! 🤦 strlen would be a fine replacement for sizeof here that would avoid all confusion.

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.

Code in manual has 1 error + 1 warning - requires changes that could result in unexpected results
2 participants