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

version 1.1.1.2, 2013/10/14 07:56:35 version 1.1.1.3, 2014/06/15 16:12:54
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) {
         /* strftime() does not guarantee to NUL-terminate so we must check. */
         buf[sizeof(buf) - 1] = '\0';
         if (strftime(buf, sizeof(buf), log_year ? "%h %e %T %Y" : "%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), log_year ? "%h %e %T %Y" : "%h %e %T",  
         timeptr) != 0 && 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.2  
changed lines
  Added in v.1.1.1.3


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