1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-17 15:05:02 -05:00

sasl_sspi: Free the Kerberos V5 challenge as soon as we're done with it

Reduced the amount of free's required for the decoded challenge message
in Curl_sasl_create_gssapi_security_message() as a result of coding it
differently in the sasl_gssapi module.
This commit is contained in:
Steve Holme 2014-12-05 00:18:13 +00:00
parent ee1d729ce0
commit 697592b3dd

View File

@ -1046,18 +1046,16 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
return CURLE_BAD_CONTENT_ENCODING; return CURLE_BAD_CONTENT_ENCODING;
} }
/* Copy the data out and free the SSPI allocated buffer as it is not required /* Copy the data out and free the challenge as it is not required anymore */
anymore */
memcpy(&indata, input_buf[1].pvBuffer, 4); memcpy(&indata, input_buf[1].pvBuffer, 4);
s_pSecFn->FreeContextBuffer(input_buf[1].pvBuffer); s_pSecFn->FreeContextBuffer(input_buf[1].pvBuffer);
Curl_safefree(chlg);
/* Extract the security layer */ /* Extract the security layer */
sec_layer = indata & 0x000000FF; sec_layer = indata & 0x000000FF;
if(!(sec_layer & KERB_WRAP_NO_ENCRYPT)) { if(!(sec_layer & KERB_WRAP_NO_ENCRYPT)) {
infof(data, "GSSAPI handshake failure (invalid security layer)\n"); infof(data, "GSSAPI handshake failure (invalid security layer)\n");
Curl_safefree(chlg);
return CURLE_BAD_CONTENT_ENCODING; return CURLE_BAD_CONTENT_ENCODING;
} }
@ -1074,17 +1072,13 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
/* Allocate the trailer */ /* Allocate the trailer */
trailer = malloc(sizes.cbSecurityTrailer); trailer = malloc(sizes.cbSecurityTrailer);
if(!trailer) { if(!trailer)
Curl_safefree(chlg);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
}
/* Convert the user name to UTF8 when operating with Unicode */ /* Convert the user name to UTF8 when operating with Unicode */
user_name = Curl_convert_tchar_to_UTF8(names.sUserName); user_name = Curl_convert_tchar_to_UTF8(names.sUserName);
if(!user_name) { if(!user_name) {
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -1094,7 +1088,6 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
message = malloc(messagelen); message = malloc(messagelen);
if(!message) { if(!message) {
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
Curl_unicodefree(user_name); Curl_unicodefree(user_name);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
@ -1114,7 +1107,6 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
if(!padding) { if(!padding) {
Curl_safefree(message); Curl_safefree(message);
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -1140,7 +1132,6 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
Curl_safefree(padding); Curl_safefree(padding);
Curl_safefree(message); Curl_safefree(message);
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -1153,7 +1144,6 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
Curl_safefree(padding); Curl_safefree(padding);
Curl_safefree(message); Curl_safefree(message);
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -1174,7 +1164,6 @@ CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
Curl_safefree(padding); Curl_safefree(padding);
Curl_safefree(message); Curl_safefree(message);
Curl_safefree(trailer); Curl_safefree(trailer);
Curl_safefree(chlg);
return result; return result;
} }