Skip to content
Snippets Groups Projects
Commit 185ed340 authored by Steve Holme's avatar Steve Holme Committed by Daniel Stenberg
Browse files

Curl_ntlm_create_typeX_message: Added the outlen parameter

Added the output message length as a parameter to both
Curl_ntlm_create_type1_message() and Curl_ntlm_create_type3_message()
for use by future functions that require it.

Updated curl_ntlm.c to cater for the extra parameter on these two
functions.
parent d54bceba
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
bool proxy)
{
char *base64 = NULL;
size_t len = 0;
CURLcode error;
/* point to the address of the pointer that holds the string to send to the
......@@ -172,7 +173,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
case NTLMSTATE_TYPE1:
default: /* for the weird cases we (re)start here */
/* Create a type-1 message */
error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64);
error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64,
&len);
if(error)
return error;
......@@ -189,7 +192,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
case NTLMSTATE_TYPE2:
/* We already received the type-2 message, create a type-3 message */
error = Curl_ntlm_create_type3_message(conn->data, userp, passwdp,
ntlm, &base64);
ntlm, &base64, &len);
if(error)
return error;
......
......@@ -354,13 +354,15 @@ static void unicodecpy(unsigned char *dest,
* ntlm [in/out] - The ntlm data struct being used and modified.
* outptr [in/out] - The adress where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_ntlm_create_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr)
char **outptr,
size_t *outlen)
{
/* NTLM type-1 message structure:
......@@ -377,7 +379,6 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp,
*/
unsigned char ntlmbuf[NTLM_BUFSIZE];
size_t base64_sz = 0;
size_t size;
#ifdef USE_WINDOWS_SSPI
......@@ -556,7 +557,7 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp,
});
/* Return with binary blob encoded into base64 */
return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, &base64_sz);
return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen);
}
/*
......@@ -574,6 +575,7 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp,
* ntlm [in/out] - The ntlm data struct being used and modified.
* outptr [in/out] - The adress where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
......@@ -581,7 +583,8 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr)
char **outptr,
size_t *outlen)
{
/* NTLM type-3 message structure:
......@@ -602,7 +605,6 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
*/
unsigned char ntlmbuf[NTLM_BUFSIZE];
size_t base64_sz = 0;
size_t size;
#ifdef USE_WINDOWS_SSPI
......@@ -950,7 +952,7 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
#endif
/* Return with binary blob encoded into base64 */
return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, &base64_sz);
return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen);
}
#endif /* USE_NTLM */
......@@ -30,14 +30,16 @@
CURLcode Curl_ntlm_create_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr);
char **outptr,
size_t *outlen);
/* This is to generate a base64 encoded NTLM type-3 message */
CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr);
char **outptr,
size_t *outlen);
/* This is to decode a NTLM type-2 message */
CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment