]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
ab: apr_base64_encode already NUL-terminate the output.
authorYann Ylavic <ylavic@apache.org>
Fri, 22 Apr 2022 12:14:01 +0000 (12:14 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 22 Apr 2022 12:14:01 +0000 (12:14 +0000)
And returns the length including the trailing \0, so setting it at that
length is off by +1.

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

support/ab.c

index b9c055eec2f38353f05d7025ca0f311d5b78cfff..d7b6938849a28d583bb48d2ad8f485e28da9909d 100644 (file)
@@ -2413,7 +2413,6 @@ static apr_status_t open_postfile(const char *pfile)
 /* sort out command-line args and call test */
 int main(int argc, const char * const argv[])
 {
-    int l;
     char tmp[1024];
     apr_status_t status;
     apr_getopt_t *opt;
@@ -2563,8 +2562,7 @@ int main(int argc, const char * const argv[])
                 if (apr_base64_encode_len(strlen(opt_arg)) > sizeof(tmp)) {
                     err("Authentication credentials too long\n");
                 }
-                l = apr_base64_encode(tmp, opt_arg, strlen(opt_arg));
-                tmp[l] = '\0';
+                apr_base64_encode(tmp, opt_arg, strlen(opt_arg));
 
                 auth = apr_pstrcat(cntxt, auth, "Authorization: Basic ", tmp,
                                        "\r\n", NULL);
@@ -2578,8 +2576,7 @@ int main(int argc, const char * const argv[])
                 if (apr_base64_encode_len(strlen(opt_arg)) > sizeof(tmp)) {
                     err("Proxy credentials too long\n");
                 }
-                l = apr_base64_encode(tmp, opt_arg, strlen(opt_arg));
-                tmp[l] = '\0';
+                apr_base64_encode(tmp, opt_arg, strlen(opt_arg));
 
                 auth = apr_pstrcat(cntxt, auth, "Proxy-Authorization: Basic ",
                                        tmp, "\r\n", NULL);