]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* apr_base64_encode_len already includes space for the terminating zero
authorRuediger Pluem <rpluem@apache.org>
Fri, 23 Oct 2020 06:23:03 +0000 (06:23 +0000)
committerRuediger Pluem <rpluem@apache.org>
Fri, 23 Oct 2020 06:23:03 +0000 (06:23 +0000)
  and apr_base64_encode returns a zero terminated string in encoded.

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

server/util.c

index 24480019c148df15e03f5f82ed1bc87c618fd3af..f829b5668ebbe3edc2d1e69b256917d6ab845693 100644 (file)
@@ -2558,9 +2558,8 @@ AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string)
     char *encoded;
     int l = strlen(string);
 
-    encoded = (char *) apr_palloc(p, 1 + apr_base64_encode_len(l));
-    l = apr_base64_encode(encoded, string, l);
-    encoded[l] = '\0'; /* make binary sequence into string */
+    encoded = (char *) apr_palloc(p, apr_base64_encode_len(l));
+    apr_base64_encode(encoded, string, l);
 
     return encoded;
 }