Skip to content

Commit

Permalink
ntlm: Avoid unnecessary buffer allocation for SSPI based type-2 token
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-caveman2k committed Oct 16, 2014
1 parent c927c92 commit 7a91296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions lib/curl_ntlm_msgs.c
Expand Up @@ -297,13 +297,8 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
}

#ifdef USE_WINDOWS_SSPI
ntlm->type_2 = malloc(size + 1);
if(ntlm->type_2 == NULL) {
free(buffer);
return CURLE_OUT_OF_MEMORY;
}
ntlm->type_2 = buffer;
ntlm->n_type_2 = curlx_uztoul(size);
memcpy(ntlm->type_2, buffer, size);
#else
ntlm->flags = 0;

Expand Down Expand Up @@ -336,8 +331,9 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
fprintf(stderr, "\n****\n");
fprintf(stderr, "**** Header %s\n ", header);
});
#endif

free(buffer);
#endif

return CURLE_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/urldata.h
Expand Up @@ -442,7 +442,7 @@ struct ntlmdata {
size_t max_token_length;
BYTE *output_token;
int has_handles;
void *type_2;
BYTE *type_2;
unsigned long n_type_2;
#else
unsigned int flags;
Expand Down

0 comments on commit 7a91296

Please sign in to comment.