Skip to content

Commit

Permalink
crypto: fix format warning in AdditionalConfig
Browse files Browse the repository at this point in the history
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 <github@addaleax.net>

PR-URL: #36060
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
RaisinTen authored and codebytere committed Nov 22, 2020
1 parent 27f1bc0 commit 272fc79
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/crypto/crypto_keygen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -67,11 +68,11 @@ Maybe<bool> SecretKeyGenTraits::AdditionalConfig(
CHECK(args[*offset]->IsUint32());
params->length = std::trunc(args[*offset].As<Uint32>()->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<size_t>(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<uint64_t>(INT_MAX) * CHAR_BIT)
};
THROW_ERR_OUT_OF_RANGE(env, msg.c_str());
return Nothing<bool>();
}
*offset += 1;
Expand Down

0 comments on commit 272fc79

Please sign in to comment.