dovecot-2.0: Don't use static sized buffers for writing log open...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 16 20:48:21 EET 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/28ff2944d4e9
changeset: 10500:28ff2944d4e9
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 16 13:31:12 2009 -0500
description:
Don't use static sized buffers for writing log open failure errors.

diffstat:

1 file changed, 7 insertions(+), 8 deletions(-)
src/lib/failures.c |   15 +++++++--------

diffs (38 lines):

diff -r 876990dc41c2 -r 28ff2944d4e9 src/lib/failures.c
--- a/src/lib/failures.c	Wed Dec 16 13:22:32 2009 -0500
+++ b/src/lib/failures.c	Wed Dec 16 13:31:12 2009 -0500
@@ -410,13 +410,12 @@ void i_set_failure_syslog(const char *id
 
 static void open_log_file(int *fd, const char *path)
 {
-	char buf[PATH_MAX];
+	const char *str;
 
 	if (*fd != STDERR_FILENO) {
 		if (close(*fd) < 0) {
-			i_snprintf(buf, sizeof(buf),
-				   "close(%d) failed: %m", *fd);
-			(void)write_full(STDERR_FILENO, buf, strlen(buf));
+			str = t_strdup_printf("close(%d) failed: %m", *fd);
+			(void)write_full(STDERR_FILENO, str, strlen(str));
 		}
 	}
 
@@ -426,13 +425,13 @@ static void open_log_file(int *fd, const
 		*fd = open(path, O_CREAT | O_APPEND | O_WRONLY, 0600);
 		if (*fd == -1) {
 			*fd = STDERR_FILENO;
-			i_snprintf(buf, sizeof(buf),
-				   "Can't open log file %s: %m\n", path);
-			(void)write_full(STDERR_FILENO, buf, strlen(buf));
+			str = t_strdup_printf("Can't open log file %s: %m\n",
+					      path);
+			(void)write_full(STDERR_FILENO, str, strlen(str));
 			if (fd == &log_fd)
 				failure_exit(FATAL_LOGOPEN);
 			else
-				i_fatal_status(FATAL_LOGOPEN, "%s", buf);
+				i_fatal_status(FATAL_LOGOPEN, "%s", str);
 		}
 		fd_close_on_exec(*fd, TRUE);
 	}


More information about the dovecot-cvs mailing list