diff options
Diffstat (limited to 'php-5.6.9-newzic.patch')
-rw-r--r-- | php-5.6.9-newzic.patch | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/php-5.6.9-newzic.patch b/php-5.6.9-newzic.patch new file mode 100644 index 0000000..d260dad --- /dev/null +++ b/php-5.6.9-newzic.patch @@ -0,0 +1,160 @@ +From 957aa220aa175a874f429f97701eede0f1ef14d3 Mon Sep 17 00:00:00 2001 +From: Derick Rethans <github@derickrethans.nl> +Date: Sun, 26 Apr 2015 11:04:16 +0100 +Subject: [PATCH] Fixed location reading due to file format changes + +--- + ext/date/lib/parse_tz.c | 61 ++- + ext/date/lib/timezonedb.h | 1166 ++++++++++++++++++++++----------------------- + 2 files changed, 640 insertions(+), 587 deletions(-) + +diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c +index ec7c6d3..89b8af7 100644 +--- a/ext/date/lib/parse_tz.c ++++ b/ext/date/lib/parse_tz.c +@@ -49,9 +49,12 @@ + #define timelib_conv_int(l) ((l & 0x000000ff) << 24) + ((l & 0x0000ff00) << 8) + ((l & 0x00ff0000) >> 8) + ((l & 0xff000000) >> 24) + #endif + +-static void read_preamble(const unsigned char **tzf, timelib_tzinfo *tz) ++static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz) + { +- /* skip ID */ ++ uint32_t version; ++ ++ /* read ID */ ++ version = (*tzf)[3] - '0'; + *tzf += 4; + + /* read BC flag */ +@@ -63,8 +66,10 @@ static void read_preamble(const unsigned char **tzf, timelib_tzinfo *tz) + tz->location.country_code[2] = '\0'; + *tzf += 2; + +- /* skip read of preamble */ ++ /* skip rest of preamble */ + *tzf += 13; ++ ++ return version; + } + + static void read_header(const unsigned char **tzf, timelib_tzinfo *tz) +@@ -81,6 +86,14 @@ static void read_header(const unsigned char **tzf, timelib_tzinfo *tz) + *tzf += sizeof(buffer); + } + ++static void skip_transistions_64bit(const unsigned char **tzf, timelib_tzinfo *tz) ++{ ++ if (tz->timecnt) { ++ *tzf += (sizeof(int64_t) * (tz->timecnt + 1)); ++ *tzf += (sizeof(unsigned char) * (tz->timecnt + 1)); ++ } ++} ++ + static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz) + { + int32_t *buffer = NULL; +@@ -111,6 +124,21 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz) + tz->trans_idx = cbuffer; + } + ++static void skip_types_64bit(const unsigned char **tzf, timelib_tzinfo *tz) ++{ ++ *tzf += sizeof(unsigned char) * 6 * tz->typecnt; ++ *tzf += sizeof(char) * tz->charcnt; ++ if (tz->leapcnt) { ++ *tzf += sizeof(int64_t) * tz->leapcnt * 2; ++ } ++ if (tz->ttisstdcnt) { ++ *tzf += sizeof(unsigned char) * tz->ttisstdcnt; ++ } ++ if (tz->ttisgmtcnt) { ++ *tzf += sizeof(unsigned char) * tz->ttisgmtcnt; ++ } ++} ++ + static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) + { + unsigned char *buffer; +@@ -194,6 +222,18 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) + } + } + ++static void skip_posix_string(const unsigned char **tzf, timelib_tzinfo *tz) ++{ ++ int n_count = 0; ++ ++ do { ++ if (*tzf[0] == '\n') { ++ n_count++; ++ } ++ (*tzf)++; ++ } while (n_count < 2); ++} ++ + static void read_location(const unsigned char **tzf, timelib_tzinfo *tz) + { + uint32_t buffer[3]; +@@ -312,18 +352,31 @@ int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb) + return (seek_to_tz_position(&tzf, timezone, tzdb)); + } + ++static void skip_2nd_header_and_data(const unsigned char **tzf, timelib_tzinfo *tz) ++{ ++ *tzf += 20; /* skip 2nd header (preamble) */ ++ *tzf += sizeof(int32_t) * 6; /* Counts */ ++} ++ + timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) + { + const unsigned char *tzf; + timelib_tzinfo *tmp; ++ int version; + + if (seek_to_tz_position(&tzf, timezone, tzdb)) { + tmp = timelib_tzinfo_ctor(timezone); + +- read_preamble(&tzf, tmp); ++ version = read_preamble(&tzf, tmp); + read_header(&tzf, tmp); + read_transistions(&tzf, tmp); + read_types(&tzf, tmp); ++ if (version == 2) { ++ skip_2nd_header_and_data(&tzf, tmp); ++ skip_transistions_64bit(&tzf, tmp); ++ skip_types_64bit(&tzf, tmp); ++ skip_posix_string(&tzf, tmp); ++ } + read_location(&tzf, tmp); + } else { + tmp = NULL; +-- +2.1.4 + +From b5e5098c50397ed910a79ac1d64b7d0fff2c02e1 Mon Sep 17 00:00:00 2001 +From: Matteo Beccati <mbeccati@php.net> +Date: Tue, 28 Apr 2015 10:57:18 +0200 +Subject: [PATCH] Fix segfault in ext/date since 957aa2 + +--- + ext/date/lib/parse_tz.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c +index 89b8af7..32ed639 100644 +--- a/ext/date/lib/parse_tz.c ++++ b/ext/date/lib/parse_tz.c +@@ -89,8 +89,8 @@ static void read_header(const unsigned char **tzf, timelib_tzinfo *tz) + static void skip_transistions_64bit(const unsigned char **tzf, timelib_tzinfo *tz) + { + if (tz->timecnt) { +- *tzf += (sizeof(int64_t) * (tz->timecnt + 1)); +- *tzf += (sizeof(unsigned char) * (tz->timecnt + 1)); ++ *tzf += (sizeof(int64_t) * (tz->timecnt)); ++ *tzf += (sizeof(unsigned char) * (tz->timecnt)); + } + } + +-- +2.1.4 + |