Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Sep 2016 23:05:45 +0000 (UTC)
From:      "Andrey A. Chernov" <ache@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r306326 - stable/9/lib/libc/stdtime
Message-ID:  <201609252305.u8PN5j6i051163@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609252305.u8PN5j6i051163>