]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
ntlm_smb_lm_auth: ignore empty NTresponse field
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 17 Sep 2015 12:30:35 +0000 (05:30 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 17 Sep 2015 12:30:35 +0000 (05:30 -0700)
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.cc

index cbcb288feb8a1e95e33f11eb5a48528ba3e90185..9ad129ac1bdb6d24900094023194f245f387b7be 100644 (file)
@@ -288,7 +288,6 @@ ntlm_check_auth(ntlm_authenticate * auth, int auth_length)
     memcpy(pass, tmp.str, tmp.l);
     pass[min(MAX_PASSWD_LEN,tmp.l)] = '\0';
 
-#if 1
     debug("Empty LM pass detection: user: '%s', ours:'%s', his: '%s' (length: %d)\n",
           user,lmencoded_empty_pass,tmp.str,tmp.l);
     if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
@@ -302,25 +301,27 @@ ntlm_check_auth(ntlm_authenticate * auth, int auth_length)
     {
         const strhdr * str = &auth->ntresponse;
         int16_t len = le16toh(str->len);
-        int32_t offset = le32toh(str->offset);
-
-        if (len != ENCODED_PASS_LEN || offset + len > auth_length || offset == 0) {
-            debug("NT response: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", auth_length, len, offset);
-            ntlm_errno = NTLM_ERR_LOGON;
-            return NULL;
-        }
-        tmp.str = (char *)packet + offset;
-        tmp.l = len;
-
-        debug("Empty NT pass detection: user: '%s', ours:'%s', his: '%s' (length: %d)\n",
-              user,ntencoded_empty_pass,tmp.str,tmp.l);
-        if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
-            fprintf(stderr,"ERROR: Empty NT password supplied for user %s\\%s. No-auth\n", domain, user);
-            ntlm_errno = NTLM_ERR_LOGON;
-            return NULL;
+        // NT response field may be absent. that is okay.
+        if (len != 0) {
+            int32_t offset = le32toh(str->offset);
+
+            if (len != ENCODED_PASS_LEN || offset + len > auth_length || offset == 0) {
+                debug("NT response: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", auth_length, len, offset);
+                ntlm_errno = NTLM_ERR_LOGON;
+                return NULL;
+            }
+            tmp.str = (char *)packet + offset;
+            tmp.l = len;
+
+            debug("Empty NT pass detection: user: '%s', ours:'%s', his: '%s' (length: %d)\n",
+                  user,ntencoded_empty_pass,tmp.str,tmp.l);
+            if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
+                fprintf(stderr,"ERROR: Empty NT password supplied for user %s\\%s. No-auth\n", domain, user);
+                ntlm_errno = NTLM_ERR_LOGON;
+                return NULL;
+            }
         }
     }
-#endif
 
     debug("checking domain: '%s', user: '%s', pass='%s'\n", domain, user, pass);