From owner-svn-src-stable-10@freebsd.org Wed Mar 1 01:44:41 2017 Return-Path: Delivered-To: svn-src-stable-10@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 A2D30CF2E71; Wed, 1 Mar 2017 01:44:41 +0000 (UTC) (envelope-from emaste@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 4A7E5A32; Wed, 1 Mar 2017 01:44:41 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v211ieIX054785; Wed, 1 Mar 2017 01:44:40 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v211ieAf054784; Wed, 1 Mar 2017 01:44:40 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201703010144.v211ieAf054784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 1 Mar 2017 01:44:40 +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: r314446 - stable/10/contrib/tzcode/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.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Mar 2017 01:44:41 -0000 Author: emaste Date: Wed Mar 1 01:44:40 2017 New Revision: 314446 URL: https://svnweb.freebsd.org/changeset/base/314446 Log: MFC r313774: localtime: return NULL if time_t out of range of struct tm Previously we would truncate tm.tm_year for any time_t corresponding to a year that does not fit in int. This issue was discovered because it caused the bash-static build to fail when linking with LLD. As reported by Rafael EspĂ­ndola: Configure has AC_FUNC_MKTIME which expands to a test of mktime that fails with the freebsd implementation. Given that, bash compiles a mktime.o file that defines just mktime and uses localtime. That goes in a .a file that is before libc. The freebsd libc defines mktime in localtime.o, which also defines localtime among other functions. When lld sees an undefined reference to mktime from libc, it uses the bash provided one and then tries to find a definition of localtime. It is found on libc's localtime.o, but now we have a duplicated error. The reason it works with bfd is that bash doesn't use mktime directly and the undefined reference from libc is resolved to the libc implementation. It would also fail to link if bash itself directly used mktime. The bash-static configure test verifies that, for many values of t, either localtime(t) returns NULL or mktime(localtime(t)) == t. This test failed when localtime returned a truncated tm_year. This was fixed in tzcode in 2004 but has persisted in our tree since rS2708. Sponsored by: The FreeBSD Foundation Modified: stable/10/contrib/tzcode/stdtime/localtime.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/tzcode/stdtime/localtime.c ============================================================================== --- stable/10/contrib/tzcode/stdtime/localtime.c Wed Mar 1 01:19:41 2017 (r314445) +++ stable/10/contrib/tzcode/stdtime/localtime.c Wed Mar 1 01:44:40 2017 (r314446) @@ -1460,14 +1460,13 @@ const time_t * const timep; } _RWLOCK_RDLOCK(&lcl_rwlock); tzset_basic(1); - localsub(timep, 0L, p_tm); + p_tm = localsub(timep, 0L, p_tm); _RWLOCK_UNLOCK(&lcl_rwlock); - return(p_tm); } else { tzset_basic(0); - localsub(timep, 0L, &tm); - return(&tm); + p_tm = localsub(timep, 0L, &tm); } + return(p_tm); } /* @@ -1481,7 +1480,7 @@ struct tm * tmp; { _RWLOCK_RDLOCK(&lcl_rwlock); tzset_basic(1); - localsub(timep, 0L, tmp); + tmp = localsub(timep, 0L, tmp); _RWLOCK_UNLOCK(&lcl_rwlock); return tmp; }