Skip to content

Commit 3f29cbb

Browse files
posix4eMylesBorins
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 f412b1f commit 3f29cbb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/node_crypto.cc

+8-3
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,14 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
14571457
String::kNormalString, mem->length));
14581458
(void) BIO_reset(bio);
14591459

1460-
BN_ULONG exponent_word = BN_get_word(rsa->e);
1461-
BIO_printf(bio, "0x%lx", exponent_word);
1462-
1460+
uint64_t exponent_word = static_cast<uint64_t>(BN_get_word(rsa->e));
1461+
uint32_t lo = static_cast<uint32_t>(exponent_word);
1462+
uint32_t hi = static_cast<uint32_t>(exponent_word >> 32);
1463+
if (hi == 0) {
1464+
BIO_printf(bio, "0x%x", lo);
1465+
} else {
1466+
BIO_printf(bio, "0x%x%08x", hi, lo);
1467+
}
14631468
BIO_get_mem_ptr(bio, &mem);
14641469
info->Set(env->exponent_string(),
14651470
String::NewFromUtf8(env->isolate(), mem->data,

0 commit comments

Comments
 (0)