summaryrefslogtreecommitdiff
path: root/support/rotatelogs.c
diff options
context:
space:
mode:
authorBen Reser <breser@apache.org>2013-10-23 03:12:46 +0000
committerBen Reser <breser@apache.org>2013-10-23 03:12:46 +0000
commit1eb6352e2a11c297d78d07c1d4b28d8e0bc05bd1 (patch)
tree7a42dbfb10673c402fa912d033e3b42282db3156 /support/rotatelogs.c
parente2e2cd9b258774d8490cf1c197c82ae1aff97f54 (diff)
downloadhttpd-1eb6352e2a11c297d78d07c1d4b28d8e0bc05bd1.tar.gz
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
Diffstat (limited to 'support/rotatelogs.c')
-rw-r--r--support/rotatelogs.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
index 1805a58ca7..2dce33fd70 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);
}