]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
ntlm_fake_auth: polish code style (#2027)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Tue, 30 Dec 2025 01:00:03 +0000 (01:00 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 2 Jan 2026 15:01:52 +0000 (15:01 +0000)
Use `xstrncpy()` to terminate c-string instead of doing it explicitly.

src/auth/ntlm/fake/ntlm_fake_auth.cc

index bb3df8d3bb28b20045a1c4587f572e4865a01ef9..5e8aa705121e0d881ea110a2a6faa1aa819f4eff 100644 (file)
@@ -142,7 +142,6 @@ main(int argc, char *argv[])
     int decodedLen;
     char user[NTLM_MAX_FIELD_LENGTH], domain[NTLM_MAX_FIELD_LENGTH];
     char *p;
-    char helper_command[3];
     int len;
 
     setbuf(stdout, nullptr);
@@ -176,8 +175,8 @@ main(int argc, char *argv[])
         }
 
         if (buflen > 3 && NTLM_packet_debug_enabled) {
-            strncpy(helper_command, buf, 2);
-            helper_command[2] = '\0';
+            char helper_command[3];
+            xstrncpy(helper_command, buf, sizeof(helper_command));
             debug("Got '%s' from Squid with data:\n", helper_command);
             hex_dump((unsigned char *)decodedBuf, decodedLen);
         } else