From 1ae3b7fdf643751d79d12554f9bbf2743042f11f Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 20 Dec 2008 21:35:38 +0000 Subject: [PATCH] PHP 5.2.8 broke strtotime (making it leak memory badly, very obvious to cacti users): add a patch from the upstream repository to fix this. Thanks Steven Surdock for reporting the problem and testing this diff (and similar patches sent by William Yodlowsky). While there, remove a zero-byte patch that crept in before. ok robert@ --- www/php5/core/Makefile | 4 +-- .../patches/patch-ext_date_lib_parse_date_c | 29 +++++++++++++++++++ .../patches/patch-ext_date_lib_parse_date_re | 23 +++++++++++++++ .../core/patches/patch-ext_date_lib_timelib_h | 13 +++++++++ .../core/patches/patch-ext_date_php_date_c | 14 +++++++++ www/php5/core/patches/patch-main_SAPI_c | 0 6 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 www/php5/core/patches/patch-ext_date_lib_parse_date_c create mode 100644 www/php5/core/patches/patch-ext_date_lib_parse_date_re create mode 100644 www/php5/core/patches/patch-ext_date_lib_timelib_h create mode 100644 www/php5/core/patches/patch-ext_date_php_date_c delete mode 100644 www/php5/core/patches/patch-main_SAPI_c diff --git a/www/php5/core/Makefile b/www/php5/core/Makefile index 65dc21d298c..1821b568db7 100644 --- a/www/php5/core/Makefile +++ b/www/php5/core/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.39 2008/12/09 21:52:31 robert Exp $ +# $OpenBSD: Makefile,v 1.40 2008/12/20 21:35:38 sthen Exp $ COMMENT-main= server-side HTML-embedded scripting language COMMENT-fastcgi=stand-alone FastCGI version of PHP PKGNAME= php5-core-${V} -PKGNAME-main= php5-core-${V} +PKGNAME-main= php5-core-${V}p0 PKGNAME-fastcgi=php5-fastcgi-${V} DISTFILES= php-${V}.tar.gz diff --git a/www/php5/core/patches/patch-ext_date_lib_parse_date_c b/www/php5/core/patches/patch-ext_date_lib_parse_date_c new file mode 100644 index 00000000000..9d4af1d9758 --- /dev/null +++ b/www/php5/core/patches/patch-ext_date_lib_parse_date_c @@ -0,0 +1,29 @@ +from upstream cvs, fixes bug 46889, memory leak in strtotime() + +$OpenBSD: patch-ext_date_lib_parse_date_c,v 1.1 2008/12/20 21:35:38 sthen Exp $ +--- ext/date/lib/parse_date.c.orig Sun Dec 7 19:31:16 2008 ++++ ext/date/lib/parse_date.c Fri Dec 19 20:42:27 2008 +@@ -1,4 +1,4 @@ +-/* Generated by re2c 0.13.5 on Sun Oct 26 11:59:08 2008 */ ++/* Generated by re2c 0.13.5 on Thu Dec 18 15:52:22 2008 */ + /* + +----------------------------------------------------------------------+ + | PHP Version 5 | +@@ -22395,7 +22395,7 @@ timelib_time* timelib_strtotime(char *s, int len, stru + + void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options) + { +- if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) { ++ if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) { + parsed->h = 0; + parsed->i = 0; + parsed->s = 0; +@@ -22415,7 +22415,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_ + parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; + } + if (!parsed->tz_info) { +- parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL; ++ parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL; + } + if (parsed->zone_type == 0 && now->zone_type != 0) { + parsed->zone_type = now->zone_type; diff --git a/www/php5/core/patches/patch-ext_date_lib_parse_date_re b/www/php5/core/patches/patch-ext_date_lib_parse_date_re new file mode 100644 index 00000000000..c1d7465a865 --- /dev/null +++ b/www/php5/core/patches/patch-ext_date_lib_parse_date_re @@ -0,0 +1,23 @@ +from upstream cvs, fixes bug 46889, memory leak in strtotime() + +$OpenBSD: patch-ext_date_lib_parse_date_re,v 1.1 2008/12/20 21:35:38 sthen Exp $ +--- ext/date/lib/parse_date.re.orig Sun Oct 26 11:27:32 2008 ++++ ext/date/lib/parse_date.re Fri Dec 19 20:42:27 2008 +@@ -1619,7 +1619,7 @@ timelib_time* timelib_strtotime(char *s, int len, stru + + void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options) + { +- if (!(options && TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) { ++ if (!(options & TIMELIB_OVERRIDE_TIME) && parsed->have_date && !parsed->have_time) { + parsed->h = 0; + parsed->i = 0; + parsed->s = 0; +@@ -1639,7 +1639,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_ + parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; + } + if (!parsed->tz_info) { +- parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL; ++ parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL; + } + if (parsed->zone_type == 0 && now->zone_type != 0) { + parsed->zone_type = now->zone_type; diff --git a/www/php5/core/patches/patch-ext_date_lib_timelib_h b/www/php5/core/patches/patch-ext_date_lib_timelib_h new file mode 100644 index 00000000000..483c2d75381 --- /dev/null +++ b/www/php5/core/patches/patch-ext_date_lib_timelib_h @@ -0,0 +1,13 @@ +from upstream cvs, fixes bug 46889, memory leak in strtotime() + +$OpenBSD: patch-ext_date_lib_timelib_h,v 1.1 2008/12/20 21:35:38 sthen Exp $ +--- ext/date/lib/timelib.h.orig Fri Feb 22 09:48:18 2008 ++++ ext/date/lib/timelib.h Fri Dec 19 20:42:27 2008 +@@ -28,6 +28,7 @@ + + #define TIMELIB_NONE 0x00 + #define TIMELIB_OVERRIDE_TIME 0x01 ++#define TIMELIB_NO_CLONE 0x02 + + #define TIMELIB_SPECIAL_WEEKDAY 0x01 + diff --git a/www/php5/core/patches/patch-ext_date_php_date_c b/www/php5/core/patches/patch-ext_date_php_date_c new file mode 100644 index 00000000000..d74bfeae97d --- /dev/null +++ b/www/php5/core/patches/patch-ext_date_php_date_c @@ -0,0 +1,14 @@ +from upstream cvs, fixes bug 46889, memory leak in strtotime() + +$OpenBSD: patch-ext_date_php_date_c,v 1.1 2008/12/20 21:35:38 sthen Exp $ +--- ext/date/php_date.c.orig Tue Dec 2 18:01:57 2008 ++++ ext/date/php_date.c Fri Dec 19 20:42:27 2008 +@@ -1143,7 +1143,7 @@ PHP_FUNCTION(strtotime) + t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB); + error1 = error->error_count; + timelib_error_container_dtor(error); +- timelib_fill_holes(t, now, 0); ++ timelib_fill_holes(t, now, TIMELIB_NO_CLONE); + timelib_update_ts(t, tzi); + ts = timelib_date_to_int(t, &error2); + diff --git a/www/php5/core/patches/patch-main_SAPI_c b/www/php5/core/patches/patch-main_SAPI_c deleted file mode 100644 index e69de29bb2d..00000000000