summaryrefslogtreecommitdiff
path: root/encoding
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-11-27 15:23:31 +0000
committerYann Ylavic <ylavic@apache.org>2020-11-27 15:23:31 +0000
commit1622024bac013e3b978db68e91636cc5e5fa2f13 (patch)
treeba97e8b440b278744b8cc8071ae9c4dc68aee367 /encoding
parent68d31b9ab73a1358f02f48de41bf0581d5bb87ab (diff)
downloadapr-1622024bac013e3b978db68e91636cc5e5fa2f13.tar.gz
apr_base64: avoid double NUL termination in apr_pbase64_{encode,decode}()
Since apr_base64_{encode,decode}() already NUL terminate the result, it needs not be done in apr_pbase64_{encode,decode}(). The NUL byte is also included in apr_base64_decode_len(), so no need to reserve an extra one in apr_pbase64_decode() etiher. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883861 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'encoding')
-rw-r--r--encoding/apr_base64.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/encoding/apr_base64.c b/encoding/apr_base64.c
index e4fb90b59..b4b28cf75 100644
--- a/encoding/apr_base64.c
+++ b/encoding/apr_base64.c
@@ -191,11 +191,9 @@ APR_DECLARE(int) apr_base64_decode_binary(unsigned char *bufplain,
APR_DECLARE(char *) apr_pbase64_decode(apr_pool_t *p, const char *bufcoded)
{
char *decoded;
- int l;
- decoded = (char *) apr_palloc(p, 1 + apr_base64_decode_len(bufcoded));
- l = apr_base64_decode(decoded, bufcoded);
- decoded[l] = '\0'; /* make binary sequence into string */
+ decoded = (char *) apr_palloc(p, apr_base64_decode_len(bufcoded));
+ apr_base64_decode(decoded, bufcoded);
return decoded;
}
@@ -286,8 +284,7 @@ APR_DECLARE(char *) apr_pbase64_encode(apr_pool_t *p, const char *string)
int l = strlen(string);
encoded = (char *) apr_palloc(p, apr_base64_encode_len(l));
- l = apr_base64_encode(encoded, string, l);
- encoded[l] = '\0'; /* make binary sequence into string */
+ apr_base64_encode(encoded, string, l);
return encoded;
}