]> granicus.if.org Git - curl/commitdiff
SPNEGO: Fix memory leak when authentication fails
authorIsaac Boukris <iboukris@gmail.com>
Wed, 9 Nov 2016 13:37:34 +0000 (15:37 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 9 Nov 2016 14:02:02 +0000 (15:02 +0100)
If SPNEGO fails, cleanup the negotiate handle right away.

Fixes #1115

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reported-by: ashman-p
lib/http_negotiate.c

index eb17ed4f2efd0d371a21bd70bd4368fe328168cc..5ea9f3401d2ab60189731cc92e45476879601c49 100644 (file)
@@ -37,6 +37,7 @@
 CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
                               const char *header)
 {
+  CURLcode result;
   struct Curl_easy *data = conn->data;
   size_t len;
 
@@ -89,8 +90,13 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
   }
 
   /* Initilise the security context and decode our challenge */
-  return Curl_auth_decode_spnego_message(data, userp, passwdp, service, host,
-                                         header, neg_ctx);
+  result = Curl_auth_decode_spnego_message(data, userp, passwdp, service,
+                                           host, header, neg_ctx);
+
+  if(result)
+    Curl_auth_spnego_cleanup(neg_ctx);
+
+  return result;
 }
 
 CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)