]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
rotatelogs: Remove another use of a consant length buffer for errors.
authorBen Reser <breser@apache.org>
Wed, 23 Oct 2013 03:12:46 +0000 (03:12 +0000)
committerBen Reser <breser@apache.org>
Wed, 23 Oct 2013 03:12:46 +0000 (03:12 +0000)
* support/rotatelogs.c
  (doRotate): Use apr_psprintf() and %pm.  Move the destruction of the pool
    after we're done with the error message so the error string stays allocated
    long enough.

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

support/rotatelogs.c

index 1805a58ca777108397843c33d2d3144990306f8b..2dce33fd70729d7a22f155702ddb2fbc560725f6 100644 (file)
@@ -468,9 +468,7 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
         status->current = newlog;
     }
     else {
-        char error[120];
-
-        apr_strerror(rv, error, sizeof error);
+        char *error = apr_psprintf(newlog.pool, "%pm", &rv);
 
         /* Uh-oh. Failed to open the new log file. Try to clear
          * the previous log file, note the lost log entries,
@@ -480,9 +478,6 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
             exit(2);
         }
 
-        /* Throw away new state; it isn't going to be used. */
-        apr_pool_destroy(newlog.pool);
-
         /* Try to keep this error message constant length
          * in case it occurs several times. */
         apr_snprintf(status->errbuf, sizeof status->errbuf,
@@ -490,6 +485,9 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
                      "new log file, %10d messages lost: %-25.25s\n",
                      status->nMessCount, error);
 
+        /* Throw away new state; it isn't going to be used. */
+        apr_pool_destroy(newlog.pool);
+
         truncate_and_write_error(status);
     }