From 272fc794b2f0d985833438d51a58af16e8000264 Mon Sep 17 00:00:00 2001 From: raisinten Date: Tue, 10 Nov 2020 13:22:10 +0530 Subject: [PATCH] crypto: fix format warning in AdditionalConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t {aka unsigned int}` Co-authored-by: Anna Henningsen PR-URL: https://github.com/nodejs/node/pull/36060 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: James M Snell --- src/crypto/crypto_keygen.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/crypto/crypto_keygen.cc b/src/crypto/crypto_keygen.cc index ab78b7aabc694b..b37cd87da944dd 100644 --- a/src/crypto/crypto_keygen.cc +++ b/src/crypto/crypto_keygen.cc @@ -2,6 +2,7 @@ #include "allocated_buffer-inl.h" #include "async_wrap-inl.h" #include "base_object-inl.h" +#include "debug_utils-inl.h" #include "env-inl.h" #include "memory_tracker-inl.h" #include "threadpoolwork-inl.h" @@ -67,11 +68,11 @@ Maybe SecretKeyGenTraits::AdditionalConfig( CHECK(args[*offset]->IsUint32()); params->length = std::trunc(args[*offset].As()->Value() / CHAR_BIT); if (params->length > INT_MAX) { - char msg[1024]; - snprintf(msg, sizeof(msg), - "length must be less than or equal to %lu bits", - static_cast(INT_MAX) * CHAR_BIT); - THROW_ERR_OUT_OF_RANGE(env, msg); + const std::string msg{ + SPrintF("length must be less than or equal to %s bits", + static_cast(INT_MAX) * CHAR_BIT) + }; + THROW_ERR_OUT_OF_RANGE(env, msg.c_str()); return Nothing(); } *offset += 1;