]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
ap_pbase64decode(): save double NUL byte allocation and assignment.
authorYann Ylavic <ylavic@apache.org>
Fri, 27 Nov 2020 17:31:09 +0000 (17:31 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 27 Nov 2020 17:31:09 +0000 (17:31 +0000)
apr_base64_decode_len() already accounts for the NUL byte, and
apr_base64_decode() already NUL terminates the string, no need
to do it in ap_pbase64decode().

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1883872 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index f829b5668ebbe3edc2d1e69b256917d6ab845693..72aa54d31d19a1d942c8db52ffc6768ea2f63fbb 100644 (file)
@@ -2474,11 +2474,9 @@ char *ap_get_local_host(apr_pool_t *a)
 AP_DECLARE(char *) ap_pbase64decode(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;
 }