]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix OpenSSL build with GCC v15.1.1 [-Wformat-truncation=] (#2077)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Tue, 3 Jun 2025 12:29:30 +0000 (12:29 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Wed, 4 Jun 2025 22:00:58 +0000 (10:00 +1200)
On arm64 Fedora 42:

    src/ssl/crtd_message.cc:132:39: error: '%zd' directive output may be
        truncated writing between 1 and 19 bytes into a region
        of size 10 [-Werror=format-truncation=]
        snprintf(buffer, sizeof(buffer), "%zd", body.length());

src/ssl/crtd_message.cc

index 84f9d181f644916c184938efac0f7e9604a6aa27..0fd518dabcd4d5e1f9973bc3512e0c1abb3a0fb5 100644 (file)
@@ -128,9 +128,7 @@ void Ssl::CrtdMessage::setCode(std::string const & aCode) { code = aCode; }
 std::string Ssl::CrtdMessage::compose() const
 {
     if (code.empty()) return std::string();
-    char buffer[10];
-    snprintf(buffer, sizeof(buffer), "%zd", body.length());
-    return code + ' ' + buffer + ' ' + body;
+    return code + ' ' + std::to_string(body.length()) + ' ' + body;
 }
 
 void Ssl::CrtdMessage::clear()