diff options
author | Yang Tse <yangsita@gmail.com> | 2011-08-24 08:07:36 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-08-24 08:10:30 +0200 |
commit | fd00b382b2d33ef90c6f5c840a32b66c8ceb1662 (patch) | |
tree | e95c73f96e5b4e67059326823e68ce78fc6f300b /lib/curl_ntlm.c | |
parent | cce6508242ab73cca896788ad9f968b89e5f9f3a (diff) | |
download | curl-fd00b382b2d33ef90c6f5c840a32b66c8ceb1662.tar.gz |
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/curl_ntlm.c')
-rw-r--r-- | lib/curl_ntlm.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/curl_ntlm.c b/lib/curl_ntlm.c index c0289e5d4..b555f5ab6 100644 --- a/lib/curl_ntlm.c +++ b/lib/curl_ntlm.c @@ -305,16 +305,22 @@ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, (*) -> Optional */ - size_t size; - unsigned char *buffer; + size_t size = 0; + unsigned char *buffer = NULL; + CURLcode error; #if defined(CURL_DISABLE_VERBOSE_STRINGS) || defined(USE_WINDOWS_SSPI) (void)data; #endif - size = Curl_base64_decode(header, &buffer); - if(!buffer) - return CURLE_OUT_OF_MEMORY; + error = Curl_base64_decode(header, &buffer, &size); + if(error) + return error; + + if(!buffer) { + infof(data, "NTLM handshake failure (unhandled condition)\n"); + return CURLE_REMOTE_ACCESS_DENIED; + } #ifdef USE_WINDOWS_SSPI ntlm->type_2 = malloc(size + 1); |