]> granicus.if.org Git - curl/commitdiff
http_ntlm_wb: Move the type-2 message processing into a dedicated function
authorSteve Holme <steve_holme@hotmail.com>
Wed, 15 May 2019 15:10:56 +0000 (16:10 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Wed, 15 May 2019 23:03:30 +0000 (00:03 +0100)
This brings the code inline with the other HTTP authentication mechanisms.

Closes #3890

lib/curl_ntlm_wb.c
lib/curl_ntlm_wb.h
lib/http.c

index 865f1396bbd2d9500abb10b19b7d793168047e1c..2400ff09129805ea2c7b4a8a10e2dcaa3700c681 100644 (file)
@@ -53,6 +53,8 @@
 #include "url.h"
 #include "strerror.h"
 #include "strdup.h"
+#include "strcase.h"
+
 /* The last 3 #include files should be in this order */
 #include "curl_printf.h"
 #include "curl_memory.h"
@@ -333,6 +335,30 @@ done:
   return CURLE_REMOTE_ACCESS_DENIED;
 }
 
+CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
+                            bool proxy,
+                            const char *header)
+{
+  (void) proxy;
+
+  if(!checkprefix("NTLM", header))
+    return CURLE_BAD_CONTENT_ENCODING;
+
+  header += strlen("NTLM");
+  while(*header && ISSPACE(*header))
+    header++;
+
+  if(*header) {
+    conn->challenge_header = strdup(header);
+    if(!conn->challenge_header)
+      return CURLE_OUT_OF_MEMORY;
+  }
+  else
+    return CURLE_BAD_CONTENT_ENCODING;
+
+  return CURLE_OK;
+}
+
 /*
  * This is for creating ntlm header output by delegating challenge/response
  * to Samba's winbind daemon helper ntlm_auth.
index 919e9636a66b00fac143a9939466fa78a002fa23..3cf841cf245c6033049bd7064175972f23f6b108 100644 (file)
 #if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
     defined(NTLM_WB_ENABLED)
 
-/* this is for creating ntlm header output by delegating challenge/response
-   to Samba's winbind daemon helper ntlm_auth */
+/* this is for ntlm header input */
+CURLcode Curl_input_ntlm_wb(struct connectdata *conn, bool proxy,
+                            const char *header);
+
+/* this is for creating ntlm header output */
 CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy);
 
 void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn);
index 222f7f53db673bcfb47b313d7a5cb1bfe7590f98..68259f817a7798a0577158f7a9d6d9abb507df2e 100644 (file)
@@ -919,19 +919,10 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
                 *availp |= CURLAUTH_NTLM_WB;
                 authp->avail |= CURLAUTH_NTLM_WB;
 
-                /* Get the challenge-message which will be passed to
-                 * ntlm_auth for generating the type 3 message later */
-                while(*auth && ISSPACE(*auth))
-                  auth++;
-                if(checkprefix("NTLM", auth)) {
-                  auth += strlen("NTLM");
-                  while(*auth && ISSPACE(*auth))
-                    auth++;
-                  if(*auth) {
-                    conn->challenge_header = strdup(auth);
-                    if(!conn->challenge_header)
-                      return CURLE_OUT_OF_MEMORY;
-                  }
+                result = Curl_input_ntlm_wb(conn, proxy, auth);
+                if(result) {
+                  infof(data, "Authentication problem. Ignoring this.\n");
+                  data->state.authproblem = TRUE;
                 }
               }
 #endif