aboutsummaryrefslogtreecommitdiffstats
path: root/lib/http_negotiate.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/http_negotiate.c')
-rw-r--r--lib/http_negotiate.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c
index 956f7342..80b0b507 100644
--- a/lib/http_negotiate.c
+++ b/lib/http_negotiate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -277,6 +277,7 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
&conn->data->state.negotiate;
char *encoded = NULL;
size_t len;
+ char *userp;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if(checkprefix("Negotiate", neg_ctx->protocol)) {
@@ -305,9 +306,15 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
infof(conn->data, "Make SPNEGO Initial Token failed\n");
}
else {
- free(neg_ctx->output_token.value);
+ free(responseToken);
responseToken = NULL;
+ free(neg_ctx->output_token.value);
neg_ctx->output_token.value = malloc(spnegoTokenLength);
+ if(neg_ctx->output_token.value == NULL) {
+ free(spnegoToken);
+ spnegoToken = NULL;
+ return CURLE_OUT_OF_MEMORY;
+ }
memcpy(neg_ctx->output_token.value, spnegoToken,spnegoTokenLength);
neg_ctx->output_token.length = spnegoTokenLength;
free(spnegoToken);
@@ -324,12 +331,16 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
if(len == 0)
return CURLE_OUT_OF_MEMORY;
- conn->allocptr.userpwd =
- aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
- neg_ctx->protocol, encoded);
+ userp = aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
+ neg_ctx->protocol, encoded);
+
+ if(proxy)
+ conn->allocptr.proxyuserpwd = userp;
+ else
+ conn->allocptr.userpwd = userp;
free(encoded);
Curl_cleanup_negotiate (conn->data);
- return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
+ return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
}
static void cleanup(struct negotiatedata *neg_ctx)