Diff for /embedaddon/sudo/plugins/sudoers/timestr.c between versions 1.1.1.1 and 1.1.1.3

version 1.1.1.1, 2013/07/22 10:46:12 version 1.1.1.3, 2014/06/15 16:12:54
Line 33 Line 33
 char *get_timestr(time_t, int);  char *get_timestr(time_t, int);
   
 /*  /*
 * Return an ascii string with the current date + time * Return a static buffer with the current date + time.
  * Uses strftime() if available, else falls back to ctime().   * Uses strftime() if available, else falls back to ctime().
  */   */
 char *  char *
Line 44  get_timestr(time_t tstamp, int log_year) Line 44  get_timestr(time_t tstamp, int log_year)
     static char buf[128];      static char buf[128];
     struct tm *timeptr;      struct tm *timeptr;
   
    timeptr = localtime(&tstamp);    if ((timeptr = localtime(&tstamp)) != NULL) {
    if (log_year)        /* strftime() does not guarantee to NUL-terminate so we must check. */
        s = "%h %e %T %Y";        buf[sizeof(buf) - 1] = '\0';
    else        if (strftime(buf, sizeof(buf), log_year ? "%h %e %T %Y" : "%h %e %T",
        s = "%h %e %T";            timeptr) != 0 && buf[sizeof(buf) - 1] == '\0')
             return buf;
     }
   
     /* strftime() does not guarantee to NUL-terminate so we must check. */  
     buf[sizeof(buf) - 1] = '\0';  
     if (strftime(buf, sizeof(buf), s, timeptr) && buf[sizeof(buf) - 1] == '\0')  
         return buf;  
   
 #endif /* HAVE_STRFTIME */  #endif /* HAVE_STRFTIME */
   
    s = ctime(&tstamp) + 4;                /* skip day of the week */    s = ctime(&tstamp);
    if (log_year)    if (s != NULL) {
        s[20] = '\0';                   /* avoid the newline */        s += 4;                         /* skip day of the week */
    else        if (log_year)
        s[15] = '\0';                   /* don't care about year */            s[20] = '\0';               /* avoid the newline */
         else
             s[15] = '\0';               /* don't care about year */
     }
   
     return s;      return s;
 }  }

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>