]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2022-2127: ntlm_auth: cap lanman response length value
authorRalph Boehme <slow@samba.org>
Fri, 16 Jun 2023 10:28:47 +0000 (12:28 +0200)
committerJule Anger <janger@samba.org>
Fri, 14 Jul 2023 13:16:16 +0000 (15:16 +0200)
We already copy at most sizeof(request.data.auth_crap.lm_resp) bytes to the
lm_resp buffer, but we don't cap the length indicator.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15072

Signed-off-by: Ralph Boehme <slow@samba.org>
source3/utils/ntlm_auth.c

index ceb22e597f7bc50847f049e8eda4f04d011fef1c..8ce453f4b924cefc0fdf7755cfbc898d1e62400e 100644 (file)
@@ -576,10 +576,14 @@ NTSTATUS contact_winbind_auth_crap(const char *username,
        memcpy(request.data.auth_crap.chal, challenge->data, MIN(challenge->length, 8));
 
        if (lm_response && lm_response->length) {
+               size_t capped_lm_response_len = MIN(
+                       lm_response->length,
+                       sizeof(request.data.auth_crap.lm_resp));
+
                memcpy(request.data.auth_crap.lm_resp,
                       lm_response->data,
-                      MIN(lm_response->length, sizeof(request.data.auth_crap.lm_resp)));
-               request.data.auth_crap.lm_resp_len = lm_response->length;
+                      capped_lm_response_len);
+               request.data.auth_crap.lm_resp_len = capped_lm_response_len;
        }
 
        if (nt_response && nt_response->length) {