Skip to content

Commit df07944

Browse files
committed
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: (35 commits) drop exec perm on doc files fix test for 5.4/5.5 add test for previous fix NEWS NEWS NEWS Fix regression introduce in fix for bug #67118 update news update NEWS Fix tests Fix possible segfault depending on memory location... fix gcov data with some locales (again) fix gcov data with some locales (again) Update NEWS Fixed startup segfault in non-debug builds Fixes issue #87 Fixed regression introduced by patch for bug #67072 Fixed bug #67329 fileinfo: NULL pointer deference flaw by processing certain CDF files (re)add cve number in NEWS, from 5.4.29 NEWS NEWS ...
2 parents 112bf73 + d4cfc15 commit df07944

23 files changed

+329
-74
lines changed

Makefile.gcov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ php_lcov.info: lcov-test
1414
@rm -rf lcov_data/
1515
@$(mkinstalldirs) lcov_data/
1616
@echo
17-
-@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.c -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | $(EGREP) $(LCOV_INCLUDE) | sed -e 's/.libs/ZZZZ/g' | sort -h | sed -e 's/ZZZZ/.libs/g' | uniq` ;\
17+
-@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.c -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | $(EGREP) $(LCOV_INCLUDE) | sed -e 's/.libs/zzzz/g' | sort | sed -e 's/zzzz/.libs/g' | uniq` ;\
1818
for x in $$files; do \
1919
echo -n . ;\
2020
y=`echo $$x | sed -e 's!\.libs/!!'`; \

README.namespaces

100755100644
File mode changed.

UPGRADING

100755100644
File mode changed.

ext/date/php_date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
25692569
err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
25702570
}
25712571
if (err && err->error_count) {
2572+
timelib_time_dtor(dateobj->time);
2573+
dateobj->time = 0;
25722574
return 0;
25732575
}
25742576

@@ -2716,9 +2718,7 @@ PHP_METHOD(DateTime, __construct)
27162718

27172719
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
27182720
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|SO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
2719-
if (!php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC)) {
2720-
ZVAL_NULL(getThis());
2721-
}
2721+
php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC);
27222722
}
27232723
zend_restore_error_handling(&error_handling TSRMLS_CC);
27242724
}

ext/date/tests/bug67118.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Bug #67118 php-cgi crashes regularly on IIS 7
2+
Bug #67118 crashes in DateTime when this used after failed __construct
33
--INI--
44
date.timezone=Europe/Berlin
55
--FILE--
@@ -11,17 +11,17 @@ class mydt extends datetime
1111
if (!empty($tz) && !is_object($tz)) {
1212
$tz = new DateTimeZone($tz);
1313
}
14-
15-
@parent::__construct($time, $tz);
14+
try {
15+
@parent::__construct($time, $tz);
16+
} catch (Exception $e) {
17+
echo "Bad date" . $this->format("Y") . "\n";
18+
}
1619
}
1720

1821
};
1922

2023
new mydt("Funktionsansvarig rådgivning och juridik", "UTC");
24+
?>
2125
--EXPECTF--
22-
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (Funktionsansvarig rådgivning och juridik) at position 0 (F): The timezone could not be found in the database' in %sbug67118.php:%d
23-
Stack trace:
24-
#0 %sbug67118.php(%d): DateTime->__construct('Funktionsansvar...', Object(DateTimeZone))
25-
#1 %sbug67118.php(%d): mydt->__construct('Funktionsansvar...', 'UTC')
26-
#2 {main}
27-
thrown in %sbug67118.php on line %d
26+
Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %sbug67118.php on line %d
27+
Bad date

ext/date/tests/bug67118_2.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Regression introduce in fix for Bug #67118
3+
--INI--
4+
date.timezone=Europe/Paris
5+
--FILE--
6+
<?php
7+
class Foo extends DateTime {
8+
public function __construct($time = null) {
9+
$tz = new DateTimeZone('UTC');
10+
try {
11+
echo "First try\n";
12+
parent::__construct($time, $tz);
13+
return;
14+
} catch (Exception $e) {
15+
echo "Second try\n";
16+
parent::__construct($time.'C', $tz);
17+
}
18+
}
19+
}
20+
$date = '12 Sep 2007 15:49:12 UT';
21+
var_dump(new Foo($date));
22+
?>
23+
Done
24+
--EXPECTF--
25+
First try
26+
Second try
27+
object(Foo)#1 (3) {
28+
["date"]=>
29+
string(%d) "2007-09-12 15:49:%s"
30+
["timezone_type"]=>
31+
int(3)
32+
["timezone"]=>
33+
string(3) "UTC"
34+
}
35+
Done

ext/fileinfo/libmagic.patch

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
822822
}
823823
diff -u libmagic.orig/cdf.c libmagic/cdf.c
824824
--- libmagic.orig/cdf.c Tue Feb 26 17:20:42 2013
825-
+++ libmagic/cdf.c Fri Feb 21 00:21:27 2014
825+
+++ libmagic/cdf.c Tue May 27 22:28:51 2014
826826
@@ -43,7 +43,17 @@
827827
#include <err.h>
828828
#endif
@@ -853,7 +853,63 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
853853
return -1;
854854

855855
return (ssize_t)len;
856-
@@ -1132,7 +1145,7 @@
856+
@@ -810,6 +823,10 @@
857+
i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
858+
if (inp[i].pi_type & CDF_VECTOR) {
859+
nelements = CDF_GETUINT32(q, 1);
860+
+ if (nelements == 0) {
861+
+ DPRINTF(("CDF_VECTOR with nelements == 0\n"));
862+
+ goto out;
863+
+ }
864+
o = 2;
865+
} else {
866+
nelements = 1;
867+
@@ -884,7 +901,9 @@
868+
}
869+
DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
870+
nelements));
871+
- for (j = 0; j < nelements; j++, i++) {
872+
+ for (j = 0; j < nelements && i < sh.sh_properties;
873+
+ j++, i++)
874+
+ {
875+
uint32_t l = CDF_GETUINT32(q, o);
876+
inp[i].pi_str.s_len = l;
877+
inp[i].pi_str.s_buf = (const char *)
878+
@@ -929,7 +948,7 @@
879+
cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
880+
cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
881+
{
882+
- size_t i, maxcount;
883+
+ size_t maxcount;
884+
const cdf_summary_info_header_t *si =
885+
CAST(const cdf_summary_info_header_t *, sst->sst_tab);
886+
const cdf_section_declaration_t *sd =
887+
@@ -944,21 +963,13 @@
888+
ssi->si_os = CDF_TOLE2(si->si_os);
889+
ssi->si_class = si->si_class;
890+
cdf_swap_class(&ssi->si_class);
891+
- ssi->si_count = CDF_TOLE2(si->si_count);
892+
+ ssi->si_count = CDF_TOLE4(si->si_count);
893+
*count = 0;
894+
maxcount = 0;
895+
*info = NULL;
896+
- for (i = 0; i < CDF_TOLE4(si->si_count); i++) {
897+
- if (i >= CDF_LOOP_LIMIT) {
898+
- DPRINTF(("Unpack summary info loop limit"));
899+
- errno = EFTYPE;
900+
- return -1;
901+
- }
902+
- if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
903+
- info, count, &maxcount) == -1) {
904+
+ if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info,
905+
+ count, &maxcount) == -1)
906+
return -1;
907+
- }
908+
- }
909+
return 0;
910+
}
911+
912+
@@ -1132,7 +1143,7 @@
857913
cdf_directory_t *d;
858914
char name[__arraycount(d->d_name)];
859915
cdf_stream_t scn;
@@ -862,7 +918,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
862918

863919
static const char *types[] = { "empty", "user storage",
864920
"user stream", "lockbytes", "property", "root storage" };
865-
@@ -1185,7 +1198,7 @@
921+
@@ -1185,7 +1196,7 @@
866922
cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
867923
{
868924
cdf_timestamp_t tp;
@@ -871,7 +927,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
871927
char buf[64];
872928
size_t i, j;
873929

874-
@@ -1229,7 +1242,11 @@
930+
@@ -1229,7 +1240,11 @@
875931
break;
876932
case CDF_FILETIME:
877933
tp = info[i].pi_tp;
@@ -885,7 +941,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
885941
} else {
886942
diff -u libmagic.orig/cdf.h libmagic/cdf.h
887943
--- libmagic.orig/cdf.h Thu Jun 21 00:19:55 2012
888-
+++ libmagic/cdf.h Fri Feb 21 00:21:27 2014
944+
+++ libmagic/cdf.h Tue May 27 22:28:51 2014
889945
@@ -35,10 +35,12 @@
890946
#ifndef _H_CDF_
891947
#define _H_CDF_
@@ -2543,7 +2599,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
25432599
}
25442600
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
25452601
--- libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014
2546-
+++ libmagic/readcdf.c Thu Apr 24 20:07:51 2014
2602+
+++ libmagic/readcdf.c Tue May 27 22:28:51 2014
25472603
@@ -30,7 +30,11 @@
25482604
#endif
25492605

ext/fileinfo/libmagic/cdf.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "file.h"
3636

3737
#ifndef lint
38-
FILE_RCSID("@(#)$File: cdf.c,v 1.53 2013/02/26 16:20:42 christos Exp $")
38+
FILE_RCSID("@(#)$File: cdf.c,v 1.55 2014/02/27 23:26:17 christos Exp $")
3939
#endif
4040

4141
#include <assert.h>
@@ -365,10 +365,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
365365
size_t ss = CDF_SHORT_SEC_SIZE(h);
366366
size_t pos = CDF_SHORT_SEC_POS(h, id);
367367
assert(ss == len);
368-
if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
368+
if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
369369
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
370370
SIZE_T_FORMAT "u\n",
371-
pos, CDF_SEC_SIZE(h) * sst->sst_len));
371+
pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
372372
return -1;
373373
}
374374
(void)memcpy(((char *)buf) + offs,
@@ -688,11 +688,13 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
688688

689689
int
690690
cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
691-
const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn)
691+
const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn,
692+
const cdf_directory_t **root)
692693
{
693694
size_t i;
694695
const cdf_directory_t *d;
695696

697+
*root = NULL;
696698
for (i = 0; i < dir->dir_len; i++)
697699
if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_ROOT_STORAGE)
698700
break;
@@ -701,6 +703,7 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
701703
if (i == dir->dir_len)
702704
goto out;
703705
d = &dir->dir_tab[i];
706+
*root = d;
704707

705708
/* If the it is not there, just fake it; some docs don't have it */
706709
if (d->d_stream_first_sector < 0)

ext/fileinfo/libmagic/cdf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ int cdf_read_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
300300
int cdf_read_ssat(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
301301
cdf_sat_t *);
302302
int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
303-
const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *);
303+
const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *,
304+
const cdf_directory_t **);
304305
int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
305306
cdf_property_info_t **, size_t *, size_t *);
306307
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,

0 commit comments

Comments
 (0)