aboutsummaryrefslogtreecommitdiff
path: root/lib/http_negotiate_sspi.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-08-24 08:07:36 +0200
committerYang Tse <yangsita@gmail.com>2011-08-24 08:10:30 +0200
commitfd00b382b2d33ef90c6f5c840a32b66c8ceb1662 (patch)
treee95c73f96e5b4e67059326823e68ce78fc6f300b /lib/http_negotiate_sspi.c
parentcce6508242ab73cca896788ad9f968b89e5f9f3a (diff)
base64: fix Curl_base64_encode and Curl_base64_decode interfaces
Previous interfaces for these libcurl internal functions did not allow to tell apart a legitimate zero size result from an error condition. These functions now return a CURLcode indicating function success or otherwise specific error. Output size is returned using a pointer argument. All usage of these two functions, and others closely related, has been adapted to the new interfaces. Relative error and OOM handling adapted or added where missing. Unit test 1302 also adapted.
Diffstat (limited to 'lib/http_negotiate_sspi.c')
-rw-r--r--lib/http_negotiate_sspi.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/http_negotiate_sspi.c b/lib/http_negotiate_sspi.c
index 875ed3cfd..08d016274 100644
--- a/lib/http_negotiate_sspi.c
+++ b/lib/http_negotiate_sspi.c
@@ -82,7 +82,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
{
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
- BYTE *input_token = 0;
+ BYTE *input_token = 0;
SecBufferDesc out_buff_desc;
SecBuffer out_sec_buff;
SecBufferDesc in_buff_desc;
@@ -94,6 +94,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
size_t len = 0, input_token_len = 0;
bool gss = FALSE;
const char* protocol;
+ CURLcode error;
while(*header && ISSPACE(*header))
header++;
@@ -176,9 +177,10 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
if(!input_token)
return -1;
- input_token_len = Curl_base64_decode(header,
- (unsigned char **)&input_token);
- if(input_token_len == 0)
+ error = Curl_base64_decode(header,
+ (unsigned char **)&input_token,
+ &input_token_len);
+ if(error || input_token_len == 0)
return -1;
}
@@ -238,16 +240,19 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
char *encoded = NULL;
- size_t len;
+ size_t len = 0;
char *userp;
+ CURLcode error;
- len = Curl_base64_encode(conn->data,
- (const char*)neg_ctx->output_token,
- neg_ctx->output_token_length,
- &encoded);
+ error = Curl_base64_encode(conn->data,
+ (const char*)neg_ctx->output_token,
+ neg_ctx->output_token_length,
+ &encoded, &len);
+ if(error)
+ return error;
if(len == 0)
- return CURLE_OUT_OF_MEMORY;
+ return CURLE_REMOTE_ACCESS_DENIED;
userp = aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
neg_ctx->protocol, encoded);