diff options
Diffstat (limited to 'nslcd/log.c')
-rw-r--r-- | nslcd/log.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/nslcd/log.c b/nslcd/log.c index 56b5936..b0e205d 100644 --- a/nslcd/log.c +++ b/nslcd/log.c @@ -155,6 +155,7 @@ void log_setrequest(const char *format, ...) void log_log(int pri, const char *format, ...) { char *msg = NULL; + char *tmp = NULL; va_list ap; #ifndef TLS char *sessionid, *requestid; @@ -165,9 +166,18 @@ void log_log(int pri, const char *format, ...) /* make the message */ va_start(ap, format); if (vasprintf(&msg, format, ap) < 0) { - fprintf(stderr, SD_ERR "vasprintf() in logger failed"); + fprintf(stderr, SD_ERR "vasprintf() failed: %s", strerror(errno)); + return; } va_end(ap); + if (errno != 0) { + if (asprintf(&tmp, "%s: %s", msg, strerror(errno)) < 0) { + fprintf(stderr, SD_ERR "asprintf() failed: %s", strerror(errno)); + } else { + free(msg); + msg = tmp; + errno = 0; + } } /* do the logging */ |