Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10770 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72189 invoked by uid 1010); 25 Jun 2004 11:22:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72143 invoked from network); 25 Jun 2004 11:22:00 -0000 Received: from unknown (HELO mail.wp-sa.pl) (212.77.102.105) by pb1.pair.com with SMTP; 25 Jun 2004 11:22:00 -0000 Received: from [10.10.1.130] (it.wp-sa.pl [212.77.105.136]) by mail.wp-sa.pl (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0HZV00HPN3KO6L@mail.wp-sa.pl> for internals@lists.php.net; Fri, 25 Jun 2004 13:22:00 +0200 (CEST) Date: Fri, 25 Jun 2004 13:21:27 +0200 To: internals@lists.php.net Message-ID: <40DC0AB7.7020901@wp-sa.pl> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_fqHKtTv+f34VJo/n2vgKgw)" X-Accept-Language: pl, en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040514 Subject: reentrancy in date/time functions (PHP_4_3) From: wmeler@wp-sa.pl (Wojtek Meler) --Boundary_(ID_fqHKtTv+f34VJo/n2vgKgw) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT Hi ! Here is small patch which makes ext/standard/datetime.c & parsedate.y use reentrant versions of date/time functions declared in PHP (php_localtime_r & php_gmtime_r). May somebody commit it ? Regards, Wojtek --Boundary_(ID_fqHKtTv+f34VJo/n2vgKgw) Content-type: text/plain; name=time_reentrancy.patch Content-transfer-encoding: 7BIT Content-disposition: inline; filename=time_reentrancy.patch Index: datetime.c =================================================================== RCS file: /repository/php-src/ext/standard/datetime.c,v retrieving revision 1.96.2.15 diff -u -r1.96.2.15 datetime.c --- datetime.c 31 Mar 2004 17:59:28 -0000 1.96.2.15 +++ datetime.c 25 Jun 2004 11:15:29 -0000 @@ -222,12 +222,12 @@ */ if (is_dst == -1) { struct tm t1, t2; - t1 = *localtime(&t); - t2 = *localtime(&seconds); + php_localtime_r(&t,&t1); + php_localtime_r(&seconds,&t2); if (t1.tm_isdst != t2.tm_isdst) { seconds += (t1.tm_isdst == 1) ? 3600 : -3600; - ta = localtime(&seconds); + ta = php_localtime_r(&seconds,&tmbuf); } /* Index: parsedate.y =================================================================== RCS file: /repository/php-src/ext/standard/parsedate.y,v retrieving revision 1.34.2.7 diff -u -r1.34.2.7 parsedate.y --- parsedate.y 8 Apr 2004 19:21:46 -0000 1.34.2.7 +++ parsedate.y 25 Jun 2004 11:15:30 -0000 @@ -967,13 +967,13 @@ time_t php_parse_date(char *p, time_t *now) { - struct tm tm, tm0, *tmp; + struct tm tm, tm0, *tmp, tmbuf; time_t Start; struct date_yy date; date.yyInput = p; Start = now ? *now : time ((time_t *) NULL); - tmp = localtime (&Start); + tmp = php_localtime_r (&Start, &tmbuf); if (!tmp) return -1; date.yyYear = tmp->tm_year + TM_YEAR_ORIGIN; @@ -1072,7 +1072,8 @@ if (date.yyHaveZone) { long delta; - struct tm *gmt = gmtime (&Start); + struct tm tmbuf; + struct tm *gmt = php_gmtime_r (&Start, &tmbuf); if (!gmt) return -1; delta = date.yyTimezone * 60L + difftm (&tm, gmt); --Boundary_(ID_fqHKtTv+f34VJo/n2vgKgw)--