diff options
Diffstat (limited to 'contrib/openpam/lib/openpam_log.c')
-rw-r--r-- | contrib/openpam/lib/openpam_log.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/openpam/lib/openpam_log.c b/contrib/openpam/lib/openpam_log.c index d733b690da7b..b15c6e35c728 100644 --- a/contrib/openpam/lib/openpam_log.c +++ b/contrib/openpam/lib/openpam_log.c @@ -34,6 +34,7 @@ * $Id$ */ +#include <ctype.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -54,7 +55,7 @@ _openpam_log(int level, const char *func, const char *fmt, ...) { va_list ap; char *format; - int priority; + int len, priority; switch (level) { case PAM_LOG_DEBUG: @@ -71,9 +72,14 @@ _openpam_log(int level, const char *func, const char *fmt, ...) break; } va_start(ap, fmt); - if ((format = malloc(strlen(func) + strlen(fmt) + 8)) != NULL) { - sprintf(format, "in %s(): %s", func, fmt); + for (len = strlen(fmt); len > 0 && isspace(fmt[len]); len--) + /* nothing */; + if ((format = malloc(strlen(func) + len + 16)) != NULL) { + sprintf(format, "in %s(): %.*s\n", func, len, fmt); vsyslog(priority, format, ap); +#ifdef DEBUG + vfprintf(stderr, format, ap); +#endif free(format); } else { vsyslog(priority, fmt, ap); |