]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
ntlm_sspi_auth: memcmp not memcpy, send newline, no uninit mem (#2218)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Mon, 8 Sep 2025 16:25:18 +0000 (16:25 +0000)
committerFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Mon, 8 Sep 2025 19:41:51 +0000 (20:41 +0100)
Previously, memcpy was incorrectly used instead of memcmp. In addition
to this, uninitalized memory could be used, and responses to Squid were
missing a newline.

src/auth/ntlm/SSPI/ntlm_sspi_auth.cc

index ec42ca76776fecfa377db76f42c30efe993e465d..f94b8f4d46f02ed009eb8e5593a64736f06454ed 100644 (file)
@@ -175,10 +175,10 @@ ntlm_check_auth(ntlm_authenticate * auth, char *user, char *domain, int auth_len
 {
     char credentials[DNLEN+UNLEN+2];    /* we can afford to waste */
 
+    user[0] = '\0';
+    domain[0] = '\0';
     if (!NTLM_LocalCall) {
 
-        user[0] = '\0';
-        domain[0] = '\0';
         const auto x = ntlm_unpack_auth(auth, user, domain, auth_length);
 
         if (x != NtlmError::None)
@@ -327,7 +327,7 @@ manage_request()
 
     /* NP: for some reason this helper sometimes needs to accept
      * from clients that send no negotiate packet. */
-    if (memcpy(local_nego.hdr.signature, "NTLMSSP", 8) != 0) {
+    if (memcmp(local_nego.hdr.signature, "NTLMSSP", 8) != 0) {
         memset(&local_nego, 0, sizeof(ntlm_negotiate)); /* reset */
         memcpy(local_nego.hdr.signature, "NTLMSSP", 8);     /* set the signature */
         local_nego.hdr.type = le32toh(NTLM_NEGOTIATE);      /* this is a challenge */
@@ -498,7 +498,7 @@ manage_request()
             /* let's lowercase them for our convenience */
             lc(domain);
             lc(user);
-            fprintf(stdout, "OK user=\"%s\\%s\"", domain, user);
+            fprintf(stdout, "OK user=\"%s\\%s\"\n", domain, user);
             return 1;
         }
         default: