Skip to content

Commit ef2fa56

Browse files
posix4eitaloacasas
authored andcommitted
src: fix string format mistake for 32 bit node
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]>
1 parent ee736b2 commit ef2fa56

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/node_crypto.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,9 +1536,14 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
15361536
String::kNormalString, mem->length));
15371537
(void) BIO_reset(bio);
15381538

1539-
BN_ULONG exponent_word = BN_get_word(rsa->e);
1540-
BIO_printf(bio, "0x%lx", exponent_word);
1541-
1539+
uint64_t exponent_word = static_cast<uint64_t>(BN_get_word(rsa->e));
1540+
uint32_t lo = static_cast<uint32_t>(exponent_word);
1541+
uint32_t hi = static_cast<uint32_t>(exponent_word >> 32);
1542+
if (hi == 0) {
1543+
BIO_printf(bio, "0x%x", lo);
1544+
} else {
1545+
BIO_printf(bio, "0x%x%08x", hi, lo);
1546+
}
15421547
BIO_get_mem_ptr(bio, &mem);
15431548
info->Set(env->exponent_string(),
15441549
String::NewFromUtf8(env->isolate(), mem->data,

0 commit comments

Comments
 (0)