summaryrefslogtreecommitdiffstats
path: root/lib/base64.c
diff options
context:
space:
mode:
authorCurl Upstream <curl-library@lists.haxx.se>2022-04-27 06:11:01 (GMT)
committerBrad King <brad.king@kitware.com>2022-04-28 19:15:44 (GMT)
commit2a9bc9ebf09fbafa5378d143083434204e9f233e (patch)
treed55420489c10068efaa694b96db2f735539b4339 /lib/base64.c
parenta1f6ec647cfab8d613897562f8ee5f81a8f6b68d (diff)
downloadCMake-2a9bc9ebf09fbafa5378d143083434204e9f233e.zip
CMake-2a9bc9ebf09fbafa5378d143083434204e9f233e.tar.gz
CMake-2a9bc9ebf09fbafa5378d143083434204e9f233e.tar.bz2
curl 2022-04-27 (1669b17d)
Code extracted from: https://github.com/curl/curl.git at commit 1669b17d3a1a1fd824308544ca0ec02a2a4f50ea (curl-7_83_0).
Diffstat (limited to 'lib/base64.c')
-rw-r--r--lib/base64.c35
1 files changed, 6 insertions, 29 deletions
diff --git a/lib/base64.c b/lib/base64.c
index be6f163..960a1ca 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2022, 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
@@ -34,7 +34,6 @@
#include "urldata.h" /* for the Curl_easy definition */
#include "warnless.h"
#include "curl_base64.h"
-#include "non-ascii.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -176,19 +175,15 @@ CURLcode Curl_base64_decode(const char *src,
}
static CURLcode base64_encode(const char *table64,
- struct Curl_easy *data,
const char *inputbuff, size_t insize,
char **outptr, size_t *outlen)
{
- CURLcode result;
unsigned char ibuf[3];
unsigned char obuf[4];
int i;
int inputparts;
char *output;
char *base64data;
- char *convbuf = NULL;
-
const char *indata = inputbuff;
*outptr = NULL;
@@ -206,20 +201,6 @@ static CURLcode base64_encode(const char *table64,
if(!output)
return CURLE_OUT_OF_MEMORY;
- /*
- * The base64 data needs to be created using the network encoding
- * not the host encoding. And we can't change the actual input
- * so we copy it to a buffer, translate it, and use that instead.
- */
- result = Curl_convert_clone(data, indata, insize, &convbuf);
- if(result) {
- free(output);
- return result;
- }
-
- if(convbuf)
- indata = (char *)convbuf;
-
while(insize > 0) {
for(i = inputparts = 0; i < 3; i++) {
if(insize > 0) {
@@ -270,10 +251,8 @@ static CURLcode base64_encode(const char *table64,
/* Return the pointer to the new data (allocated memory) */
*outptr = base64data;
- free(convbuf);
-
/* Return the length of the new data */
- *outlen = strlen(base64data);
+ *outlen = output - base64data;
return CURLE_OK;
}
@@ -295,11 +274,10 @@ static CURLcode base64_encode(const char *table64,
*
* @unittest: 1302
*/
-CURLcode Curl_base64_encode(struct Curl_easy *data,
- const char *inputbuff, size_t insize,
+CURLcode Curl_base64_encode(const char *inputbuff, size_t insize,
char **outptr, size_t *outlen)
{
- return base64_encode(base64, data, inputbuff, insize, outptr, outlen);
+ return base64_encode(base64, inputbuff, insize, outptr, outlen);
}
/*
@@ -319,11 +297,10 @@ CURLcode Curl_base64_encode(struct Curl_easy *data,
*
* @unittest: 1302
*/
-CURLcode Curl_base64url_encode(struct Curl_easy *data,
- const char *inputbuff, size_t insize,
+CURLcode Curl_base64url_encode(const char *inputbuff, size_t insize,
char **outptr, size_t *outlen)
{
- return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
+ return base64_encode(base64url, inputbuff, insize, outptr, outlen);
}
#endif /* no users so disabled */