Author: ache
Date: Sun Sep 25 23:05:44 2016
New Revision: 306326
URL: https://svnweb.freebsd.org/changeset/base/306326

Log:
  MFC r272562,r272678,r272679
  
  1) Fix the case we have less arguments for format string than we expected.
  2) Return error on unsupported format specs.
  (both according to POSIX)
  3) For %Z format, understand "UTC" name too.
  
  PR:     93197 (only r272679)

Modified:
  stable/9/lib/libc/stdtime/strptime.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libc/   (props changed)
  stable/9/lib/libc/stdtime/   (props changed)

Modified: stable/9/lib/libc/stdtime/strptime.c
==============================================================================
--- stable/9/lib/libc/stdtime/strptime.c        Sun Sep 25 22:57:59 2016        
(r306325)
+++ stable/9/lib/libc/stdtime/strptime.c        Sun Sep 25 23:05:44 2016        
(r306326)
@@ -103,9 +103,6 @@ _strptime(const char *buf, const char *f
 
        ptr = fmt;
        while (*ptr != 0) {
-               if (*buf == 0)
-                       break;
-
                c = *ptr++;
 
                if (c != '%') {
@@ -123,7 +120,6 @@ _strptime(const char *buf, const char *f
 label:
                c = *ptr++;
                switch (c) {
-               case 0:
                case '%':
                        if (*buf++ != '%')
                                return (NULL);
@@ -552,7 +548,8 @@ label:
                                strncpy(zonestr, buf, cp - buf);
                                zonestr[cp - buf] = '\0';
                                tzset();
-                               if (0 == strcmp(zonestr, "GMT")) {
+                               if (0 == strcmp(zonestr, "GMT") ||
+                                   0 == strcmp(zonestr, "UTC")) {
                                    *GMTp = 1;
                                } else if (0 == strcmp(zonestr, tzname[0])) {
                                    tm->tm_isdst = 0;
@@ -599,6 +596,9 @@ label:
                        while (isspace_l((unsigned char)*buf, locale))
                                buf++;
                        break;
+
+               default:
+                       return (NULL);
                }
        }
 
@@ -674,6 +674,7 @@ strptime_l(const char * __restrict buf, 
        ret = _strptime(buf, fmt, tm, &gmt, loc);
        if (ret && gmt) {
                time_t t = timegm(tm);
+
                localtime_r(&t, tm);
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to