diff options
author | Ben Reser <breser@apache.org> | 2013-10-23 05:12:46 +0200 |
---|---|---|
committer | Ben Reser <breser@apache.org> | 2013-10-23 05:12:46 +0200 |
commit | 1eb6352e2a11c297d78d07c1d4b28d8e0bc05bd1 (patch) | |
tree | 7a42dbfb10673c402fa912d033e3b42282db3156 | |
parent | rotatelogs: Use apr_psprintf() with %pm instead of a constant length buffer for (diff) | |
download | apache2-1eb6352e2a11c297d78d07c1d4b28d8e0bc05bd1.tar.xz apache2-1eb6352e2a11c297d78d07c1d4b28d8e0bc05bd1.zip |
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
-rw-r--r-- | support/rotatelogs.c | 10 |
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); } |