From 8ff25f503a751f7b7ec4e787837fda51c6570d24 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 15 Mar 2012 19:24:16 -0700 Subject: [PATCH] Use args list only once. Probably better to use an intermediate buffer anyway. --- guacd/src/log.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/guacd/src/log.c b/guacd/src/log.c index bfd55db7..1cdaed04 100644 --- a/guacd/src/log.c +++ b/guacd/src/log.c @@ -47,25 +47,29 @@ void vguacd_log_info(const char* format, va_list args) { + /* Copy log message into buffer */ + char message[2048]; + vsnprintf(message, sizeof(message), format, args); + /* Log to syslog */ - vsyslog(LOG_INFO, format, args); + syslog(LOG_INFO, "%s", message); /* Log to STDERR */ - fprintf(stderr, "guacd[%i]: INFO: ", getpid()); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); + fprintf(stderr, "guacd[%i]: INFO: %s\n", getpid(), message); } void vguacd_log_error(const char* format, va_list args) { + /* Copy log message into buffer */ + char message[2048]; + vsnprintf(message, sizeof(message), format, args); + /* Log to syslog */ - vsyslog(LOG_ERR, format, args); + syslog(LOG_ERR, "%s", message); /* Log to STDERR */ - fprintf(stderr, "guacd[%i]: ERROR: ", getpid()); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); + fprintf(stderr, "guacd[%i]: ERROR: %s\n", getpid(), message); }