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/http_digest.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/http_digest.c')
-rw-r--r-- | lib/http_digest.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/http_digest.c b/lib/http_digest.c index 3ca0389e9..b41e62306 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -280,7 +280,8 @@ CURLcode Curl_output_digest(struct connectdata *conn, unsigned char *ha1; unsigned char ha2[33];/* 32 digits and 1 zero byte */ char cnoncebuf[7]; - char *cnonce; + char *cnonce = NULL; + size_t cnonce_sz = 0; char *tmp = NULL; struct timeval now; @@ -343,10 +344,12 @@ CURLcode Curl_output_digest(struct connectdata *conn, /* Generate a cnonce */ now = Curl_tvnow(); snprintf(cnoncebuf, sizeof(cnoncebuf), "%06ld", (long)now.tv_sec); - if(Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf), &cnonce)) - d->cnonce = cnonce; - else - return CURLE_OUT_OF_MEMORY; + + rc = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf), + &cnonce, &cnonce_sz); + if(rc) + return rc; + d->cnonce = cnonce; } /* |