summaryrefslogtreecommitdiff
path: root/support/rotatelogs.c
diff options
context:
space:
mode:
authorBen Reser <breser@apache.org>2013-10-23 03:01:05 +0000
committerBen Reser <breser@apache.org>2013-10-23 03:01:05 +0000
commite2e2cd9b258774d8490cf1c197c82ae1aff97f54 (patch)
tree87af06b02146d38b204733a34e9023a1f4d91c7a /support/rotatelogs.c
parent11a39fba77c14d914f362e88d242dfd949f0f17b (diff)
downloadhttpd-e2e2cd9b258774d8490cf1c197c82ae1aff97f54.tar.gz
rotatelogs: Use apr_psprintf() with %pm instead of a constant length buffer for
errors. * support/rotatelogs.c (post_rotate, doRotate): Switch to using apr_psprintf() with %pm. Suggested by: rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1534895 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/rotatelogs.c')
-rw-r--r--support/rotatelogs.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
index 63869ae34a..1805a58ca7 100644
--- a/support/rotatelogs.c
+++ b/support/rotatelogs.c
@@ -267,7 +267,6 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
rotate_config_t *config, rotate_status_t *status)
{
apr_status_t rv;
- char error[120];
apr_procattr_t *pattr;
const char *argv[4];
apr_proc_t proc;
@@ -280,9 +279,9 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
}
rv = apr_file_link(newlog->name, config->linkfile);
if (rv != APR_SUCCESS) {
- apr_strerror(rv, error, sizeof error);
- fprintf(stderr, "Error linking file %s to %s (%s)\n",
- newlog->name, config->linkfile, error);
+ char *error = apr_psprintf(pool, "Error linking file %s to %s (%pm)\n",
+ newlog->name, config->linkfile, &rv);
+ fputs(error, stderr);
exit(2);
}
}
@@ -297,10 +296,9 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
/* noop */;
if ((rv = apr_procattr_create(&pattr, pool)) != APR_SUCCESS) {
- fprintf(stderr,
- "post_rotate: apr_procattr_create failed for '%s': %s\n",
- config->postrotate_prog,
- apr_strerror(rv, error, sizeof(error)));
+ char *error = apr_psprintf(pool, "post_rotate: apr_procattr_create failed " \
+ "for '%s': %pm\n", config->postrotate_prog, &rv);
+ fputs(error, stderr);
return;
}
@@ -309,10 +307,10 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
rv = apr_procattr_cmdtype_set(pattr, APR_PROGRAM_ENV);
if (rv != APR_SUCCESS) {
- fprintf(stderr,
- "post_rotate: could not set up process attributes for '%s': %s\n",
- config->postrotate_prog,
- apr_strerror(rv, error, sizeof(error)));
+ char *error = apr_psprintf(pool, "post_rotate: could not set up process " \
+ "attributes for '%s': %pm\n", config->postrotate_prog,
+ &rv);
+ fputs(error, stderr);
return;
}
@@ -331,9 +329,9 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
rv = apr_proc_create(&proc, argv[0], argv, NULL, pattr, pool);
if (rv != APR_SUCCESS) {
- fprintf(stderr, "Could not spawn post-rotate process '%s': %s\n",
- config->postrotate_prog,
- apr_strerror(rv, error, sizeof(error)));
+ char *error = apr_psprintf(pool, "Could not spawn post-rotate process " \
+ "'%s': %pm\n", config->postrotate_prog, &rv);
+ fputs(error, stderr);
return;
}
}
@@ -442,10 +440,10 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
}
rv = apr_dir_make_recursive(path, APR_FPROT_OS_DEFAULT, newlog.pool);
if (rv != APR_SUCCESS) {
- char error[120];
-
- apr_strerror(rv, error, sizeof error);
- fprintf(stderr, "Could not create directory '%s' (%s)\n", path, error);
+ char *error = apr_psprintf(newlog.pool,
+ "Could not create directory '%s' (%pm)\n",
+ path, &rv);
+ fputs(error, stderr);
exit(2);
}
}