[BACK]Return to ssh-keygen.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ssh-keygen.c between version 1.313 and 1.314

version 1.313, 2018/02/23 15:58:38 version 1.314, 2018/03/12 00:52:01
Line 1782 
Line 1782 
         return now + (u_int64_t)(secs * mul);          return now + (u_int64_t)(secs * mul);
 }  }
   
 static u_int64_t  
 parse_absolute_time(const char *s)  
 {  
         struct tm tm;  
         time_t tt;  
         char buf[32], *fmt;  
   
         /*  
          * POSIX strptime says "The application shall ensure that there  
          * is white-space or other non-alphanumeric characters between  
          * any two conversion specifications" so arrange things this way.  
          */  
         switch (strlen(s)) {  
         case 8:  
                 fmt = "%Y-%m-%d";  
                 snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2s", s, s + 4, s + 6);  
                 break;  
         case 14:  
                 fmt = "%Y-%m-%dT%H:%M:%S";  
                 snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s",  
                     s, s + 4, s + 6, s + 8, s + 10, s + 12);  
                 break;  
         default:  
                 fatal("Invalid certificate time format \"%s\"", s);  
         }  
   
         memset(&tm, 0, sizeof(tm));  
         if (strptime(buf, fmt, &tm) == NULL)  
                 fatal("Invalid certificate time %s", s);  
         if ((tt = mktime(&tm)) < 0)  
                 fatal("Certificate time %s cannot be represented", s);  
         return (u_int64_t)tt;  
 }  
   
 static void  static void
 parse_cert_times(char *timespec)  parse_cert_times(char *timespec)
 {  {
Line 1851 
Line 1817 
                 cert_valid_from = parse_relative_time(from, now);                  cert_valid_from = parse_relative_time(from, now);
         else if (strcmp(from, "always") == 0)          else if (strcmp(from, "always") == 0)
                 cert_valid_from = 0;                  cert_valid_from = 0;
         else          else if (parse_absolute_time(from, &cert_valid_from) != 0)
                 cert_valid_from = parse_absolute_time(from);                  fatal("Invalid from time \"%s\"", from);
   
         if (*to == '-' || *to == '+')          if (*to == '-' || *to == '+')
                 cert_valid_to = parse_relative_time(to, now);                  cert_valid_to = parse_relative_time(to, now);
         else if (strcmp(to, "forever") == 0)          else if (strcmp(to, "forever") == 0)
                 cert_valid_to = ~(u_int64_t)0;                  cert_valid_to = ~(u_int64_t)0;
         else          else if (parse_absolute_time(to, &cert_valid_to) != 0)
                 cert_valid_to = parse_absolute_time(to);                  fatal("Invalid to time \"%s\"", to);
   
         if (cert_valid_to <= cert_valid_from)          if (cert_valid_to <= cert_valid_from)
                 fatal("Empty certificate validity interval");                  fatal("Empty certificate validity interval");

Legend:
Removed from v.1.313  
changed lines
  Added in v.1.314