1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

krb5: Small code tidy up

* Prefer dereference of string pointer rather than strlen()
* Free challenge pointer in one place
* Additional comments
This commit is contained in:
Steve Holme 2016-04-03 17:30:51 +01:00
parent 156b8287a7
commit 1d451bdd99
2 changed files with 7 additions and 7 deletions

View File

@ -113,7 +113,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
free(spn); free(spn);
} }
if(chlg64 && strlen(chlg64)) { if(chlg64 && *chlg64) {
/* Decode the base-64 encoded challenge message */ /* Decode the base-64 encoded challenge message */
if(*chlg64 != '=') { if(*chlg64 != '=') {
result = Curl_base64_decode(chlg64, &chlg, &chlglen); result = Curl_base64_decode(chlg64, &chlg, &chlglen);
@ -144,6 +144,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
mutual_auth, mutual_auth,
NULL); NULL);
/* Free the decoded challenge as it is not required anymore */
free(input_token.value); free(input_token.value);
if(GSS_ERROR(major_status)) { if(GSS_ERROR(major_status)) {

View File

@ -113,6 +113,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
} }
if(!krb5->credentials) { if(!krb5->credentials) {
/* Do we have credientials to use or are we using single sign-on? */
if(userp && *userp) { if(userp && *userp) {
/* Populate our identity structure */ /* Populate our identity structure */
result = Curl_create_sspi_identity(userp, passwdp, &krb5->identity); result = Curl_create_sspi_identity(userp, passwdp, &krb5->identity);
@ -151,7 +152,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
memset(krb5->context, 0, sizeof(CtxtHandle)); memset(krb5->context, 0, sizeof(CtxtHandle));
} }
if(chlg64 && strlen(chlg64)) { if(chlg64 && *chlg64) {
/* Decode the base-64 encoded challenge message */ /* Decode the base-64 encoded challenge message */
if(*chlg64 != '=') { if(*chlg64 != '=') {
result = Curl_base64_decode(chlg64, &chlg, &chlglen); result = Curl_base64_decode(chlg64, &chlg, &chlglen);
@ -195,9 +196,10 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
&resp_desc, &attrs, &resp_desc, &attrs,
&expiry); &expiry);
if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) { /* Free the decoded challenge as it is not required anymore */
free(chlg); free(chlg);
if(status != SEC_E_OK && status != SEC_I_CONTINUE_NEEDED) {
return CURLE_RECV_ERROR; return CURLE_RECV_ERROR;
} }
@ -218,9 +220,6 @@ CURLcode Curl_auth_create_gssapi_user_message(struct SessionHandle *data,
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
} }
/* Free the decoded challenge */
free(chlg);
return result; return result;
} }