Lines 1-53
Link Here
|
1 |
diff --git a/ntlm.h b/ntlm.h |
|
|
2 |
index 1469633..ad83520 100644 |
3 |
--- a/ntlm.h |
4 |
+++ b/ntlm.h |
5 |
@@ -32,8 +32,8 @@ uint32 msgType; |
6 |
tSmbStrHeader uDomain; |
7 |
uint32 flags; |
8 |
uint8 challengeData[8]; |
9 |
-uint8 reserved[8]; |
10 |
-tSmbStrHeader emptyString; |
11 |
+uint32 context[2]; |
12 |
+tSmbStrHeader targetInfo; |
13 |
uint8 buffer[1024]; |
14 |
uint32 bufIndex; |
15 |
}tSmbNtlmAuthChallenge; |
16 |
diff --git a/ntlmsubr.c b/ntlmsubr.c |
17 |
index f9d2733..63cbed8 100644 |
18 |
--- a/ntlmsubr.c |
19 |
+++ b/ntlmsubr.c |
20 |
@@ -55,7 +55,32 @@ int ntlm_helper(int sock, struct query *ctl, const char *proto) |
21 |
if ((result = gen_recv(sock, msgbuf, sizeof msgbuf))) |
22 |
goto cancelfail; |
23 |
|
24 |
- (void)from64tobits (&challenge, msgbuf, sizeof(challenge)); |
25 |
+ if ((result = from64tobits (&challenge, msgbuf, sizeof(challenge))) < 0 |
26 |
+ || result < ((void *)&challenge.context - (void *)&challenge)) |
27 |
+ { |
28 |
+ report (stderr, GT_("could not decode BASE64 challenge\n")); |
29 |
+ /* We do not goto cancelfail; the server has already sent the |
30 |
+ * tagged reply, so the protocol exchange has ended, no need |
31 |
+ * for us to send the asterisk. */ |
32 |
+ return PS_AUTHFAIL; |
33 |
+ } |
34 |
+ |
35 |
+ /* validate challenge: |
36 |
+ * - ident |
37 |
+ * - message type |
38 |
+ * - that offset points into buffer |
39 |
+ * - that offset + length does not wrap |
40 |
+ * - that offset + length is not bigger than buffer */ |
41 |
+ if (0 != memcmp("NTLMSSP", challenge.ident, 8) |
42 |
+ || challenge.msgType != 2 |
43 |
+ || challenge.uDomain.offset > result |
44 |
+ || challenge.uDomain.offset + challenge.uDomain.len < challenge.uDomain.offset |
45 |
+ || challenge.uDomain.offset + challenge.uDomain.len > result) |
46 |
+ { |
47 |
+ report (stderr, GT_("NTLM challenge contains invalid data.\n")); |
48 |
+ result = PS_AUTHFAIL; |
49 |
+ goto cancelfail; |
50 |
+ } |
51 |
|
52 |
if (outlevel >= O_DEBUG) |
53 |
dumpSmbNtlmAuthChallenge(stdout, &challenge); |