-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: fix string format mistake for 32 bit node #10082
Conversation
# endif | ||
# ifdef THIRTY_TWO_BIT | ||
BIO_printf(bio, "0x%dx", exponent_word); | ||
# endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A less ifdef-y approach would be BIO_printf(bio, "0x%llx", static_cast<uint64_t>(exponent_word));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get
foo.c:16:65: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
BIO_printf(bio, "0x%llx", static_cast<uint64_t>(exponent_word));
When I try 64bit mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BIO_printf(bio, "0x%llx", static_cast<long long unsigned>(exponent_word));
works though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh damn but then I get
src/node_crypto.cc:1540: Use int16/int64/etc, rather than the C type long [runtime/int] [4]
c78cee8
to
cca4236
Compare
I think this gets us the best of both worlds @bnoordhuis ? |
I'm fairly sure Visual Studio doesn't have inttypes.h but we'll find out soon enough: https://ci.nodejs.org/job/node-test-pull-request/5099/ |
Looks like you were right? Shall we go back to ifdefs ? |
Windows passed? |
Looks like nothing passed. Maybe I should try the #ifdef approach again? |
@posix4e Lots of other stuff failed, but it looks like windows did indeed pass. https://ci.nodejs.org/job/node-test-commit-windows-fanned/5557/ |
Forgive my noobness but what are the next steps? Shall I return the ifdefs or is this sufficient? Does anyone agree about the merit of the patch?It seems windows might have passed (again excuse my noob) what is causing the other build failures? |
Ok going back to my original ifdef patch unless anyone has some suggestions? |
BIO_printf(bio, "0x%lx", exponent_word); | ||
|
||
# endif | ||
# ifdef THIRTY_TWO_BIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be an #else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not exactly, there's a third case that I was hoping would break. I can handle it, it only happens on VMS and alpha
# endif | ||
# ifdef THIRTY_TWO_BIT | ||
BIO_printf(bio, "0x%dx", exponent_word); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it more, what about this?
uint64_t exponent_word = static_cast<uint64_t>(BN_get_word(rsa->e));
uint32_t lo = static_cast<uint32_t>(exponent_word);
uint32_t hi = static_cast<uint32_t>(exponent_word >> 32);
if (hi == 0) {
BIO_printf(bio, "0x%x", lo);
} else {
BIO_printf(bio, "0x%x%08x", hi, lo);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIne by me. Seems less clear, but if you'd prefer
ring a ling a ding dong. Anything else we should do? |
one more run of ci: https://ci.nodejs.org/job/node-test-pull-request/5410/ oh hi @posix4e o/ also can you modify the commit to include the subsystem and under 50 characters, might I suggest |
Does this mean great build success? |
generally we don't put a colon at the end of the commit title. Otherwise the commit looks in order. I'll have to defer to @bnoordhuis for the actual review. @addaleax may be able to help out as well. |
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word);
updated commit comment |
I'll land this end of day if there are no objections |
landed in 40eba12 |
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Notable changes: * **crypto**: - Allow adding extra certificates to well-known CAs. (Sam Roberts) [#9139](#9139) * **buffer**: - Fix single-character string filling. (Anna Henningsen) [#9837](#9837) - Handle UCS2 `.fill()` properly on BE. (Anna Henningsen) [#9837](#9837) * **url**: - Add inspect function to TupleOrigin. (Safia Abdalla) [#10039](#10039) - Including base argument in originFor. (joyeecheung) [#10021](#10021) - Improve URLSearchParams spec compliance. (Timothy Gu) [#9484](#9484) * **http**: - Remove stale timeout listeners. (Karl Böhlmark) [#9440](#9440) * **build**: - Fix node_g target. (Daniel Bevenius) [#10153](#10153) * **fs**: - Remove unused argument from copyObject(). (EthanArrowood) [#10041](#10041) * **timers**: - Fix handling of cleared immediates. (hveldstra) [#9759](#9759) * **src**: - Add wrapper for process.emitWarning(). (SamRoberts) [#9139](#9139) - Fix string format mistake for 32 bit node.(Alex Newman) [#10082](#10082)
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: nodejs/node#10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] BIO_printf(bio, "0x%lx", exponent_word); PR-URL: #10082 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Checklist
make -j8 test
Affected core subsystem(s)
crypto
Description of change
I noticed a warning reminscint of a format-string vuln. I think i have made the format string correct on non alpha based systems.
The warning was