1 From b780b30d1377adb10bbe774835f49e9b237fb9bb Mon Sep 17 00:00:00 2001
2 From: Daniel Stenberg <daniel@haxx.se>
3 Date: Wed, 2 Jan 2019 20:33:08 +0100
4 Subject: [PATCH] NTLM: fix size check condition for type2 received data
6 Bug: https://curl.haxx.se/docs/CVE-2018-16890.html
7 Reported-by: Wenxiang Qian
10 lib/vauth/ntlm.c | 7 ++++---
11 1 file changed, 4 insertions(+), 3 deletions(-)
13 diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c
14 index c3d55ed251..0ad4d972e3 100644
15 --- a/lib/vauth/ntlm.c
16 +++ b/lib/vauth/ntlm.c
18 * | (__| |_| | _ <| |___
19 * \___|\___/|_| \_\_____|
21 - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
22 + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
24 * This software is licensed as described in the file COPYING, which
25 * you should have received as part of this distribution. The terms
26 @@ -182,10 +182,11 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data,
27 target_info_len = Curl_read16_le(&buffer[40]);
28 target_info_offset = Curl_read32_le(&buffer[44]);
29 if(target_info_len > 0) {
30 - if(((target_info_offset + target_info_len) > size) ||
31 + if((target_info_offset >= size) ||
32 + ((target_info_offset + target_info_len) > size) ||
33 (target_info_offset < 48)) {
34 infof(data, "NTLM handshake failure (bad type-2 message). "
35 - "Target Info Offset Len is set incorrect by the peer\n");
36 + "Target Info Offset Len is set incorrect by the peer\n");
37 return CURLE_BAD_CONTENT_ENCODING;