]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:ntlm_auth: make logs more consistent with length check
authorJones Syue <jonessyue@qnap.com>
Fri, 5 Jul 2024 09:36:46 +0000 (17:36 +0800)
committerJule Anger <janger@samba.org>
Thu, 15 Aug 2024 07:56:59 +0000 (07:56 +0000)
Run ntlm_auth with options --lm-response/--nt-response/--challenge, and pass
wrong length to these options, got error prompted logs about 'only got xxx
bytes', which are not consistent with length check. This patch revise logs
for length check to make it more consistent.

For example --lm-response requires exact 24 hex, let us input three kinds
of length 23 24 25, prompted logs said 'only got 25 bytes' seems confusing.

script:
for length in 23 24 25; \
do \
    ntlm_auth --username=${un} --password=${pw} \
    --lm-response="`openssl rand -hex ${length}`"; \
done;

output:
hex decode of 04db772593f5e6023d0ab4bc67a942c9179963477eb49d failed! (only got 23 bytes)
NT_STATUS_OK: The operation completed successfully. (0x0)
hex decode of 1e57749feb46bedcf969af6cbbe10e21d0232e35c27eb07294 failed! (only got 25 bytes)

After patch it shows 'got 25 bytes, expected 24' seems more consistent:

hex decode of e13e70c9cf2ac1e20015657c4bec53435b1b948febb63f failed! (got 23 bytes, expected 24)
NT_STATUS_OK: The operation completed successfully. (0x0)
hex decode of 64647005243092b036856f572faad262e0b69386d095d60f54 failed! (got 25 bytes, expected 24)

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

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: David Mulder <dmulder@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jul  6 00:52:02 UTC 2024 on atb-devel-224

(cherry picked from commit 90c9d0d98d3c80c77764dbcaf9c24d7c4ea31b4a)

Autobuild-User(v4-19-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-19-test): Thu Aug 15 07:56:59 UTC 2024 on atb-devel-224

source3/utils/ntlm_auth.c

index cff3c53845ffb1e097fb591bf72c8d983d28992e..74aa610f48654017b93a91e76ccd68bb03c477c6 100644 (file)
@@ -2701,7 +2701,7 @@ enum {
                        opt_challenge = strhex_to_data_blob(NULL, hex_challenge);
                        if (opt_challenge.length != 8) {
                                fprintf(stderr, "hex decode of %s failed! "
-                                       "(only got %d bytes)\n",
+                                       "(got %d bytes, expected 8)\n",
                                        hex_challenge,
                                        (int)opt_challenge.length);
                                exit(1);
@@ -2711,7 +2711,7 @@ enum {
                        opt_lm_response = strhex_to_data_blob(NULL, hex_lm_response);
                        if (opt_lm_response.length != 24) {
                                fprintf(stderr, "hex decode of %s failed! "
-                                       "(only got %d bytes)\n",
+                                       "(got %d bytes, expected 24)\n",
                                        hex_lm_response,
                                        (int)opt_lm_response.length);
                                exit(1);
@@ -2722,7 +2722,7 @@ enum {
                        opt_nt_response = strhex_to_data_blob(NULL, hex_nt_response);
                        if (opt_nt_response.length < 24) {
                                fprintf(stderr, "hex decode of %s failed! "
-                                       "(only got %d bytes)\n",
+                                       "(only got %d bytes, needed at least 24)\n",
                                        hex_nt_response,
                                        (int)opt_nt_response.length);
                                exit(1);