You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2013/10/23 05:12:46 UTC

svn commit: r1534896 - /httpd/httpd/trunk/support/rotatelogs.c

Author: breser
Date: Wed Oct 23 03:12:46 2013
New Revision: 1534896

URL: http://svn.apache.org/r1534896
Log:
rotatelogs: Remove another use of a consant length buffer for errors.

* 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.

Modified:
    httpd/httpd/trunk/support/rotatelogs.c

Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=1534896&r1=1534895&r2=1534896&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Wed Oct 23 03:12:46 2013
@@ -468,9 +468,7 @@ static void doRotate(rotate_config_t *co
         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 *co
             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 *co
                      "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);
     }