]> granicus.if.org Git - curl/commitdiff
HTTP: Free (proxy)userpwd for NTLM/Negotiate after sending a request
authorStefan Bühler <buehler@teamviewer.com>
Mon, 24 Nov 2014 08:23:07 +0000 (09:23 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 4 Dec 2014 22:46:13 +0000 (14:46 -0800)
Sending NTLM/Negotiate header again after successful authentication
breaks the connection with certain Proxies and request types (POST to MS
Forefront).

lib/http.c

index d32a012715b22cc04a985a0b611df2eba58136c1..c56689893eee663d0ef3ead87e219ee2be1e7f20 100644 (file)
@@ -2323,12 +2323,27 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
       );
 
   /*
-   * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
-   * with basic and digest, it will be freed anyway by the next request
+   * Free userpwd for Negotiate/NTLM. Cannot reuse as it is associated with
+   * the connection and shouldn't be repeated over it either.
    */
+  switch (data->state.authhost.picked) {
+  case CURLAUTH_NEGOTIATE:
+  case CURLAUTH_NTLM:
+  case CURLAUTH_NTLM_WB:
+    Curl_safefree(conn->allocptr.userpwd);
+    break;
+  }
 
-  Curl_safefree (conn->allocptr.userpwd);
-  conn->allocptr.userpwd = NULL;
+  /*
+   * Same for proxyuserpwd
+   */
+  switch (data->state.authproxy.picked) {
+  case CURLAUTH_NEGOTIATE:
+  case CURLAUTH_NTLM:
+  case CURLAUTH_NTLM_WB:
+    Curl_safefree(conn->allocptr.proxyuserpwd);
+    break;
+  }
 
   if(result)
     return result;