Changeset 51 in openpam


Ignore:
Timestamp:
Feb 13, 2002, 12:39:32 AM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

Trim whitespace off the end of the format string, and add exactly
one newline character.

If DEBUG is defined, echo the log message to STDERR.

Sponsored by: DARPA, NAI Labs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_log.c

    r37 r51  
    3535 */
    3636
     37#include <ctype.h>
    3738#include <stdarg.h>
    3839#include <stdio.h>
     
    5556        va_list ap;
    5657        char *format;
    57         int priority;
     58        int len, priority;
    5859
    5960        switch (level) {
     
    7273        }
    7374        va_start(ap, fmt);
    74         if ((format = malloc(strlen(func) + strlen(fmt) + 8)) != NULL) {
    75                 sprintf(format, "in %s(): %s", func, fmt);
     75        for (len = strlen(fmt); len > 0 && isspace(fmt[len]); len--)
     76                /* nothing */;
     77        if ((format = malloc(strlen(func) + len + 8)) != NULL) {
     78                sprintf(format, "in %s(): %.*s\n", func, len, fmt);
    7679                vsyslog(priority, format, ap);
     80#ifdef DEBUG
     81                vfprintf(stderr, format, ap);
     82#endif
    7783                free(format);
    7884        } else {
Note: See TracChangeset for help on using the changeset viewer.