diff --git a/src/pk.c b/src/pk.c index b0d866aa8..4da27c439 100644 --- a/src/pk.c +++ b/src/pk.c @@ -737,12 +737,13 @@ static int wolfssl_print_indent(WOLFSSL_BIO* bio, char* line, int lineLen, int ret = 1; if (indent > 0) { + int len_wanted; /* Cap indent to buffer size to avoid format truncation warning */ if (indent >= lineLen) { indent = lineLen - 1; } /* Print indent spaces. */ - int len_wanted = XSNPRINTF(line, (size_t)lineLen, "%*s", indent, " "); + len_wanted = XSNPRINTF(line, (size_t)lineLen, "%*s", indent, " "); if ((len_wanted < 0) || (len_wanted >= lineLen)) { WOLFSSL_ERROR_MSG("Buffer overflow formatting indentation"); ret = 0;