]> granicus.if.org Git - curl/commitdiff
gssapi: fix memory leak of output token in multi round context
authorIsaac Boukris <iboukris@gmail.com>
Fri, 21 Jul 2017 23:00:46 +0000 (02:00 +0300)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Fri, 4 Aug 2017 22:23:24 +0000 (00:23 +0200)
When multiple rounds are needed to establish a security context
(usually ntlm), we overwrite old token with a new one without free.
Found by proposed gss tests using stub a gss implementation (by
valgrind error), though I have confirmed the leak with a real
gssapi implementation as well.

Closes https://github.com/curl/curl/pull/1733

lib/vauth/spnego_gssapi.c

index 8840db8fda26139fd9ae721a19a3a7e023012c02..5196c27049ca73040ede8812df0684fb78ec4710 100644 (file)
@@ -180,6 +180,10 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
     return CURLE_OUT_OF_MEMORY;
   }
 
+  /* Free previous token */
+  if(nego->output_token.length && nego->output_token.value)
+    gss_release_buffer(&unused_status, &nego->output_token);
+
   nego->output_token = output_token;
 
   return CURLE_OK;