summaryrefslogtreecommitdiffstats
path: root/src/util/sss_log.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2014-08-26 17:29:08 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-08-27 16:44:10 +0200
commitcbc005cd63523ca7d772c9f0c7ea9a4817c2c07e (patch)
treed888732c382c58fe29e78784f4eb84044fe950dc /src/util/sss_log.c
parente87f92f04f297fbdb0ae916945513a67b8a63044 (diff)
downloadsssd-cbc005cd63523ca7d772c9f0c7ea9a4817c2c07e.tar.gz
sssd-cbc005cd63523ca7d772c9f0c7ea9a4817c2c07e.tar.xz
sssd-cbc005cd63523ca7d772c9f0c7ea9a4817c2c07e.zip
sss_log: fix handling of variable argument lists
SSSD has two public calls to send messages to syslog sss_log() and sss_log_ext() which both expect besides other arguments a printf format string and a variable list of arguments depending on the format. Currently sss_log() calls sss_log_ext() internally after calling va_start(ap, format) and hands over ap as the last argument. This does not work because there is a difference between a varying number of arguments and a va_list type. To fix this I added a new private call which expects a va_list as the last argument and is called by sss_log() and sss_log_ext() after calling va_start(). Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/util/sss_log.c')
-rw-r--r--src/util/sss_log.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/util/sss_log.c b/src/util/sss_log.c
index 7a2dce635..48e73dbea 100644
--- a/src/util/sss_log.c
+++ b/src/util/sss_log.c
@@ -57,28 +57,40 @@ static int sss_to_syslog(int priority)
}
}
+static void sss_log_internal(int priority, int facility, const char *format,
+ va_list ap);
+
void sss_log(int priority, const char *format, ...)
{
va_list ap;
va_start(ap, format);
- sss_log_ext(priority, LOG_DAEMON, format, ap);
+ sss_log_internal(priority, LOG_DAEMON, format, ap);
va_end(ap);
}
-#ifdef WITH_JOURNALD
-
void sss_log_ext(int priority, int facility, const char *format, ...)
{
va_list ap;
+
+ va_start(ap, format);
+ sss_log_internal(priority, facility, format, ap);
+ va_end(ap);
+}
+
+
+
+#ifdef WITH_JOURNALD
+
+static void sss_log_internal(int priority, int facility, const char *format,
+ va_list ap)
+{
int syslog_priority;
int ret;
char *message;
const char *domain;
- va_start(ap, format);
ret = vasprintf(&message, format, ap);
- va_end(ap);
if (ret == -1) {
/* ENOMEM */
@@ -103,18 +115,16 @@ void sss_log_ext(int priority, int facility, const char *format, ...)
#else /* WITH_JOURNALD */
-void sss_log_ext(int priority, int facility, const char *format, ...)
+static void sss_log_internal(int priority, int facility, const char *format,
+ va_list ap)
{
- va_list ap;
int syslog_priority;
syslog_priority = sss_to_syslog(priority);
openlog(debug_prg_name, 0, facility);
- va_start(ap, format);
vsyslog(syslog_priority, format, ap);
- va_end(ap);
closelog();
}