From owner-svn-src-stable-9@freebsd.org Sun Sep 25 23:05:46 2016 Return-Path: Delivered-To: svn-src-stable-9@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A7C0BE91B0; Sun, 25 Sep 2016 23:05:46 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 006DE8F5; Sun, 25 Sep 2016 23:05:45 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8PN5jMN051164; Sun, 25 Sep 2016 23:05:45 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8PN5j6i051163; Sun, 25 Sep 2016 23:05:45 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201609252305.u8PN5j6i051163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Sun, 25 Sep 2016 23:05:45 +0000 (UTC) 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 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Sep 2016 23:05:46 -0000 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); }