Changeset 537 in openpam


Ignore:
Timestamp:
Mar 31, 2012, 4:20:13 PM (2 years ago)
Author:
des
Message:

Save errno before calling asprintf(), since asprintf() may touch errno,
which will cause syslog() to log the wrong error message if the format
string contains %m.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_log.c

    r523 r537  
    4040#endif 
    4141 
    42 #include <ctype.h> 
     42#include <errno.h> 
    4343#include <stdarg.h> 
    4444#include <stdio.h> 
    4545#include <stdlib.h> 
    46 #include <string.h> 
    4746#include <syslog.h> 
    4847 
     
    102101        char *format; 
    103102        int priority; 
     103        int serrno; 
    104104 
    105105        switch (level) { 
     
    121121        } 
    122122        va_start(ap, fmt); 
     123        serrno = errno; 
    123124        if (asprintf(&format, "in %s(): %s", func, fmt) > 0) { 
     125                errno = serrno; 
    124126                vsyslog(priority, format, ap); 
    125127                FREE(format); 
    126128        } else { 
     129                errno = serrno; 
    127130                vsyslog(priority, fmt, ap); 
    128131        } 
Note: See TracChangeset for help on using the changeset viewer.