From owner-svn-src-stable-10@FreeBSD.ORG  Sun Oct 19 21:16:25 2014
Return-Path: <owner-svn-src-stable-10@FreeBSD.ORG>
Delivered-To: svn-src-stable-10@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by hub.freebsd.org (Postfix) with ESMTPS id 5E126DC4;
 Sun, 19 Oct 2014 21:16:25 +0000 (UTC)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 49BE1951;
 Sun, 19 Oct 2014 21:16:25 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9JLGPca067648;
 Sun, 19 Oct 2014 21:16:25 GMT (envelope-from ache@FreeBSD.org)
Received: (from ache@localhost)
 by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9JLGPVM067647;
 Sun, 19 Oct 2014 21:16:25 GMT (envelope-from ache@FreeBSD.org)
Message-Id: <201410192116.s9JLGPVM067647@svn.freebsd.org>
X-Authentication-Warning: svn.freebsd.org: ache set sender to ache@FreeBSD.org
 using -f
From: "Andrey A. Chernov" <ache@FreeBSD.org>
Date: Sun, 19 Oct 2014 21:16:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject: svn commit: r273290 - stable/10/lib/libc/stdtime
X-SVN-Group: stable-10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-stable-10@freebsd.org
X-Mailman-Version: 2.1.18-1
Precedence: list
List-Id: SVN commit messages for only the 10-stable src tree
 <svn-src-stable-10.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-stable-10>, 
 <mailto:svn-src-stable-10-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable-10/>
List-Post: <mailto:svn-src-stable-10@freebsd.org>
List-Help: <mailto:svn-src-stable-10-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10>, 
 <mailto:svn-src-stable-10-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 19 Oct 2014 21:16:25 -0000

Author: ache
Date: Sun Oct 19 21:16:24 2014
New Revision: 273290
URL: https://svnweb.freebsd.org/changeset/base/273290

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

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

Modified: stable/10/lib/libc/stdtime/strptime.c
==============================================================================
--- stable/10/lib/libc/stdtime/strptime.c	Sun Oct 19 21:07:35 2014	(r273289)
+++ stable/10/lib/libc/stdtime/strptime.c	Sun Oct 19 21:16:24 2014	(r273290)
@@ -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);
 	}