From: Ben Reser Date: Wed, 23 Oct 2013 03:12:46 +0000 (+0000) Subject: rotatelogs: Remove another use of a consant length buffer for errors. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5079dca06a41aa49d2bf3f9be661743ba5b51670;p=thirdparty%2Fapache%2Fhttpd.git 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1534896 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/rotatelogs.c b/support/rotatelogs.c index 1805a58ca77..2dce33fd707 100644 --- a/support/rotatelogs.c +++ b/support/rotatelogs.c @@ -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); }