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

Format string causes undefined behavior #7

Closed
Sonic-The-Hedgehog-LNK1123 opened this issue Dec 8, 2021 · 4 comments
Closed

Format string causes undefined behavior #7

Sonic-The-Hedgehog-LNK1123 opened this issue Dec 8, 2021 · 4 comments

Comments

@Sonic-The-Hedgehog-LNK1123

The format string "60%060s%060s" at:

RegInfo.Items[1] = HelperStringFormat("60%060s%060s", LicenseTypeSignatureS.c_str(), LicenseTypeSignatureR.c_str());

and
RegInfo.Items[2] = HelperStringFormat("60%060s%060s", UserNameSignatureS.c_str(), UserNameSignatureR.c_str());

is not valid, the "0" flag cannot be combined with the "s" specifier.

The string should be replaced with "60%s%s" like this:

RegInfo.Items[1] = HelperStringFormat("60%060s%060s", LicenseTypeSignatureS.c_str(), LicenseTypeSignatureR.c_str());

should be replaced by:

RegInfo.Items[1] = HelperStringFormat("60%s%s", LicenseTypeSignatureS.c_str(), LicenseTypeSignatureR.c_str());

and

RegInfo.Items[2] = HelperStringFormat("60%060s%060s", UserNameSignatureS.c_str(), UserNameSignatureR.c_str());

should be replaced by:

RegInfo.Items[2] = HelperStringFormat("60%s%s", UserNameSignatureS.c_str(), UserNameSignatureR.c_str()); 

The changes introduced in #6 already ensure the strings to be formatted are exactly 60 chars.

@bitcookies
Copy link
Owner

Thanks, I'll take a look. 👍

@bitcookies
Copy link
Owner

I found a bug, the keys generated by Github Actions are all invalid. 😥

I can't find the reason, is it because of the cloud windows coding problem?

If you have a spare time, can you help to check it out?

@bitcookies
Copy link
Owner

I find that:

The key generated in this way is valid:

winrar-keygen.exe text1 text2"

but the key generated in this way is invalid:

winrar-keygen.exe text1 text2 > rarreg.key

@bitcookies
Copy link
Owner

Ohh. It's because powershell is outputting in UTF16-LE format by default, which is causing the error. I fixed.

Format string issues was also fixed using your suggestion. Thanks again! 😄

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

No branches or pull requests

2 participants