summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.gcov2
-rw-r--r--[-rwxr-xr-x]README.namespaces0
-rw-r--r--[-rwxr-xr-x]UPGRADING0
-rw-r--r--ext/date/php_date.c2
-rw-r--r--ext/date/tests/bug67118.phpt17
-rw-r--r--ext/date/tests/bug67118_2.phpt28
-rw-r--r--ext/fileinfo/libmagic/cdf.c11
-rw-r--r--ext/fileinfo/libmagic/cdf.h3
-rw-r--r--ext/fileinfo/libmagic/readcdf.c77
-rw-r--r--sapi/phpdbg/phpdbg.c51
-rw-r--r--sapi/phpdbg/phpdbg_watch.c2
-rw-r--r--sapi/phpdbg/tests/commands/0002_set.test2
-rw-r--r--sapi/phpdbg/tests/commands/0103_register.test10
-rw-r--r--sapi/phpdbg/tests/commands/0106_compile.test1
-rw-r--r--sapi/phpdbg/tests/run-tests.php28
15 files changed, 172 insertions, 62 deletions
diff --git a/Makefile.gcov b/Makefile.gcov
index 7157cb5ddb..8d30f34ae8 100644
--- a/Makefile.gcov
+++ b/Makefile.gcov
@@ -14,7 +14,7 @@ php_lcov.info: lcov-test
@rm -rf lcov_data/
@$(mkinstalldirs) lcov_data/
@echo
- -@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` ;\
+ -@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` ;\
for x in $$files; do \
echo -n . ;\
y=`echo $$x | sed -e 's!\.libs/!!'`; \
diff --git a/README.namespaces b/README.namespaces
index 9c427b634f..9c427b634f 100755..100644
--- a/README.namespaces
+++ b/README.namespaces
diff --git a/UPGRADING b/UPGRADING
index 740047a86a..740047a86a 100755..100644
--- a/UPGRADING
+++ b/UPGRADING
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 37266d17b5..aaa3afa04b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2529,6 +2529,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
}
if (err && err->error_count) {
+ timelib_time_dtor(dateobj->time);
+ dateobj->time = 0;
return 0;
}
diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt
index 6371757647..2aa8c1d828 100644
--- a/ext/date/tests/bug67118.phpt
+++ b/ext/date/tests/bug67118.phpt
@@ -1,5 +1,5 @@
--TEST--
-Bug #67118 php-cgi crashes regularly on IIS 7
+Bug #67118 crashes in DateTime when this used after failed __construct
--INI--
date.timezone=Europe/Berlin
--FILE--
@@ -11,17 +11,16 @@ class mydt extends datetime
if (!empty($tz) && !is_object($tz)) {
$tz = new DateTimeZone($tz);
}
-
- @parent::__construct($time, $tz);
+ try {
+ @parent::__construct($time, $tz);
+ } catch (Exception $e) {
+ echo "Bad date" . $this->format("Y") . "\n";
+ }
}
};
new mydt("Funktionsansvarig rÄdgivning och juridik", "UTC");
+?>
--EXPECTF--
-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
-Stack trace:
-#0 %sbug67118.php(%d): DateTime->__construct('Funktionsansvar...', Object(DateTimeZone))
-#1 %sbug67118.php(%d): mydt->__construct('Funktionsansvar...', 'UTC')
-#2 {main}
- thrown in %sbug67118.php on line %d
+Fatal error: Call to a member function format() on a non-object in %sbug67118.php on line %d
diff --git a/ext/date/tests/bug67118_2.phpt b/ext/date/tests/bug67118_2.phpt
new file mode 100644
index 0000000000..368d4d9401
--- /dev/null
+++ b/ext/date/tests/bug67118_2.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Regression introduce in fix for Bug #67118 - Invalid code
+--INI--
+date.timezone=Europe/Paris
+--FILE--
+<?php
+class Foo extends DateTime {
+ public function __construct($time = null) {
+ $tz = new DateTimeZone('UTC');
+ try {
+ echo "First try\n";
+ parent::__construct($time, $tz);
+ return;
+ } catch (Exception $e) {
+ echo "Second try\n";
+ parent::__construct($time.'C', $tz);
+ }
+ }
+}
+$date = '12 Sep 2007 15:49:12 UT';
+var_dump(new Foo($date));
+?>
+Done
+--EXPECTF--
+First try
+Second try
+NULL
+Done \ No newline at end of file
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
index 4712e84942..cbe3b0cf77 100644
--- a/ext/fileinfo/libmagic/cdf.c
+++ b/ext/fileinfo/libmagic/cdf.c
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.53 2013/02/26 16:20:42 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.55 2014/02/27 23:26:17 christos Exp $")
#endif
#include <assert.h>
@@ -365,10 +365,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
size_t ss = CDF_SHORT_SEC_SIZE(h);
size_t pos = CDF_SHORT_SEC_POS(h, id);
assert(ss == len);
- if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
+ if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
SIZE_T_FORMAT "u\n",
- pos, CDF_SEC_SIZE(h) * sst->sst_len));
+ pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
return -1;
}
(void)memcpy(((char *)buf) + offs,
@@ -688,11 +688,13 @@ out:
int
cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
- const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn)
+ const cdf_sat_t *sat, const cdf_dir_t *dir, cdf_stream_t *scn,
+ const cdf_directory_t **root)
{
size_t i;
const cdf_directory_t *d;
+ *root = NULL;
for (i = 0; i < dir->dir_len; i++)
if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_ROOT_STORAGE)
break;
@@ -701,6 +703,7 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
if (i == dir->dir_len)
goto out;
d = &dir->dir_tab[i];
+ *root = d;
/* If the it is not there, just fake it; some docs don't have it */
if (d->d_stream_first_sector < 0)
diff --git a/ext/fileinfo/libmagic/cdf.h b/ext/fileinfo/libmagic/cdf.h
index 70eb519465..00131e02f4 100644
--- a/ext/fileinfo/libmagic/cdf.h
+++ b/ext/fileinfo/libmagic/cdf.h
@@ -300,7 +300,8 @@ int cdf_read_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
int cdf_read_ssat(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
cdf_sat_t *);
int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
- const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *);
+ const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *,
+ const cdf_directory_t **);
int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
cdf_property_info_t **, size_t *, size_t *);
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
diff --git a/ext/fileinfo/libmagic/readcdf.c b/ext/fileinfo/libmagic/readcdf.c
index 1600625eb8..ec97ced44b 100644
--- a/ext/fileinfo/libmagic/readcdf.c
+++ b/ext/fileinfo/libmagic/readcdf.c
@@ -26,7 +26,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.37 2014/01/06 13:41:18 rrt Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.40 2014/03/06 15:23:33 christos Exp $")
#endif
#include <stdlib.h>
@@ -77,6 +77,40 @@ static const struct nv {
# define strcasestr strstr
#endif
+static const struct cv {
+ uint64_t clsid[2];
+ const char *mime;
+} clsid2mime[] = {
+ {
+#ifdef PHP_WIN32
+ { 0x00000000000c1084ui64, 0x46000000000000c0ui64 },
+#else
+ { 0x00000000000c1084LLU, 0x46000000000000c0LLU },
+#endif
+ "x-msi",
+ }
+}, clsid2desc[] = {
+ {
+#ifdef PHP_WIN32
+ { 0x00000000000c1084ui64, 0x46000000000000c0ui64 },
+#else
+ { 0x00000000000c1084LLU, 0x46000000000000c0LLU },
+#endif
+ "MSI Installer",
+ },
+};
+
+private const char *
+cdf_clsid_to_mime(const uint64_t clsid[2], const struct cv *cv)
+{
+ size_t i;
+ for (i = 0; cv[i].mime != NULL; i++) {
+ if (clsid[0] == cv[i].clsid[0] && clsid[1] == cv[i].clsid[1])
+ return cv[i].mime;
+ }
+ return NULL;
+}
+
private const char *
cdf_app_to_mime(const char *vbuf, const struct nv *nv)
{
@@ -95,7 +129,7 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
private int
cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
- size_t count)
+ size_t count, const cdf_directory_t *root_storage)
{
size_t i;
cdf_timestamp_t tp;
@@ -107,6 +141,9 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
memset(&ts, 0, sizeof(ts));
+ if (!NOTMIME(ms) && root_storage)
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2mime);
+
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
switch (info[i].pi_type) {
@@ -163,7 +200,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
buf, vbuf) == -1)
return -1;
}
- } else if (info[i].pi_id ==
+ } else if (str == NULL && info[i].pi_id ==
CDF_PROPERTY_NAME_OF_APPLICATION) {
str = cdf_app_to_mime(vbuf, app2mime);
}
@@ -217,7 +254,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
private int
cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
- const cdf_stream_t *sst)
+ const cdf_stream_t *sst, const cdf_directory_t *root_storage)
{
cdf_summary_info_header_t si;
cdf_property_info_t *info;
@@ -228,6 +265,8 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
return -1;
if (NOTMIME(ms)) {
+ const char *str;
+
if (file_printf(ms, "Composite Document File V2 Document")
== -1)
return -1;
@@ -255,9 +294,15 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
return -2;
break;
}
- }
+ if (root_storage) {
+ str = cdf_clsid_to_mime(root_storage->d_storage_uuid, clsid2desc);
+ if (str)
+ if (file_printf(ms, ", %s", str) == -1)
+ return -2;
+ }
+ }
- m = cdf_file_property_info(ms, info, count);
+ m = cdf_file_property_info(ms, info, count, root_storage);
free(info);
return m == -1 ? -2 : m;
@@ -275,6 +320,7 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
int i;
const char *expn = "";
const char *corrupt = "corrupt: ";
+ const cdf_directory_t *root_storage;
info.i_fd = fd;
info.i_buf = buf;
@@ -308,7 +354,8 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
goto out2;
}
- if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst)) == -1) {
+ if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst,
+ &root_storage)) == -1) {
expn = "Cannot read short stream";
goto out3;
}
@@ -329,23 +376,21 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
#ifdef CDF_DEBUG
cdf_dump_summary_info(&h, &scn);
#endif
- if ((i = cdf_file_summary_info(ms, &h, &scn)) < 0)
- expn = "Can't expand summary_info";
+ if ((i = cdf_file_summary_info(ms, &h, &scn, root_storage)) < 0)
+ expn = "Can't expand summary_info";
+
if (i == 0) {
const char *str = NULL;
cdf_directory_t *d;
char name[__arraycount(d->d_name)];
size_t j, k;
- for (j = 0; j < dir.dir_len; j++) {
+
+ for (j = 0; str == NULL && j < dir.dir_len; j++) {
d = &dir.dir_tab[j];
for (k = 0; k < sizeof(name); k++)
name[k] = (char)cdf_tole2(d->d_name[k]);
- if (NOTMIME(ms))
- str = cdf_app_to_mime(name, name2desc);
- else
- str = cdf_app_to_mime(name, name2mime);
- if (str != NULL)
- break;
+ str = cdf_app_to_mime(name,
+ NOTMIME(ms) ? name2desc : name2mime);
}
if (NOTMIME(ms)) {
if (str != NULL) {
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index fc121839e8..93fdbd7424 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -159,8 +159,6 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], 8, NULL, NULL, 0);
- phpdbg_setup_watchpoints(TSRMLS_C);
-
zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0);
zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0);
@@ -879,6 +877,32 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) {
}
#endif
+static inline zend_mm_heap *phpdbg_mm_get_heap() {
+ zend_mm_heap *mm_heap;
+
+ TSRMLS_FETCH();
+
+ mm_heap = zend_mm_set_heap(NULL TSRMLS_CC);
+ zend_mm_set_heap(mm_heap TSRMLS_CC);
+
+ return mm_heap;
+}
+
+void *phpdbg_malloc_wrapper(size_t size)
+{
+ return zend_mm_alloc(phpdbg_mm_get_heap(), size);
+}
+
+void phpdbg_free_wrapper(void *p)
+{
+ zend_mm_free(phpdbg_mm_get_heap(), p);
+}
+
+void *phpdbg_realloc_wrapper(void *ptr, size_t size)
+{
+ return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size);
+}
+
int main(int argc, char **argv) /* {{{ */
{
sapi_module_struct *phpdbg = &phpdbg_sapi_module;
@@ -1221,23 +1245,22 @@ phpdbg_main:
EXCEPTION_POINTERS *xp;
__try {
#endif
- zend_mm_heap *mm_heap = zend_mm_set_heap(NULL TSRMLS_CC);
-#if ZEND_DEBUG
- if (!mm_heap->use_zend_alloc) {
- mm_heap->_malloc = malloc;
- mm_heap->_realloc = realloc;
- mm_heap->_free = free;
-#endif
- PHPDBG_G(original_free_function) = mm_heap->_free;
- mm_heap->_free = phpdbg_watch_efree;
+ zend_mm_heap *mm_heap = phpdbg_mm_get_heap();
+
+ if (mm_heap->use_zend_alloc) {
+ mm_heap->_malloc = phpdbg_malloc_wrapper;
+ mm_heap->_realloc = phpdbg_realloc_wrapper;
+ mm_heap->_free = phpdbg_free_wrapper;
mm_heap->use_zend_alloc = 0;
-#if ZEND_DEBUG
}
-#endif
- zend_mm_set_heap(mm_heap TSRMLS_CC);
zend_activate(TSRMLS_C);
+ PHPDBG_G(original_free_function) = mm_heap->_free;
+ mm_heap->_free = phpdbg_watch_efree;
+
+ phpdbg_setup_watchpoints(TSRMLS_C);
+
#if defined(ZEND_SIGNALS) && !defined(_WIN32)
zend_try {
zend_signal_activate(TSRMLS_C);
diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c
index 2efbb1237c..e88622444b 100644
--- a/sapi/phpdbg/phpdbg_watch.c
+++ b/sapi/phpdbg/phpdbg_watch.c
@@ -580,7 +580,7 @@ void phpdbg_setup_watchpoints(TSRMLS_D) {
zend_llist_init(&PHPDBG_G(watchlist_mem), sizeof(void *), phpdbg_watch_mem_dtor, 1);
phpdbg_btree_init(&PHPDBG_G(watchpoint_tree), sizeof(void *) * 8);
phpdbg_btree_init(&PHPDBG_G(watch_HashTables), sizeof(void *) * 8);
- _zend_hash_init(&PHPDBG_G(watchpoints), 8, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC);
+ zend_hash_init(&PHPDBG_G(watchpoints), 8, NULL, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC);
}
static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) {
diff --git a/sapi/phpdbg/tests/commands/0002_set.test b/sapi/phpdbg/tests/commands/0002_set.test
index 7720f94fff..468ac6d9ea 100644
--- a/sapi/phpdbg/tests/commands/0002_set.test
+++ b/sapi/phpdbg/tests/commands/0002_set.test
@@ -9,7 +9,6 @@
# setting notice color
# Failed to find breakpoint #0
# oplog disabled
-# not enabled
# opened oplog test.log
# nothing
#################################################
@@ -19,5 +18,4 @@ set color notice none
set prompt promot>
set break 0
set oplog
-set oplog 0
set oplog test.log
diff --git a/sapi/phpdbg/tests/commands/0103_register.test b/sapi/phpdbg/tests/commands/0103_register.test
index 38841591ca..703a12f771 100644
--- a/sapi/phpdbg/tests/commands/0103_register.test
+++ b/sapi/phpdbg/tests/commands/0103_register.test
@@ -7,15 +7,15 @@
#[Registered test_function]
#array(5) {
# [0]=>
-# string(1) "1"
+# int(1)
# [1]=>
-# string(1) "2"
+# int(2)
# [2]=>
-# string(1) "3"
+# int(3)
# [3]=>
-# string(1) "4"
+# int(4)
# [4]=>
-# string(1) "5"
+# int(5)
#}
#################################################
<:
diff --git a/sapi/phpdbg/tests/commands/0106_compile.test b/sapi/phpdbg/tests/commands/0106_compile.test
index d79211ddf7..7193600ea3 100644
--- a/sapi/phpdbg/tests/commands/0106_compile.test
+++ b/sapi/phpdbg/tests/commands/0106_compile.test
@@ -14,6 +14,5 @@ define('OUT',
file_put_contents(OUT, "<?php echo \"Hello World\"; ?>");
phpdbg_exec(OUT);
:>
-compile
run
quit
diff --git a/sapi/phpdbg/tests/run-tests.php b/sapi/phpdbg/tests/run-tests.php
index 1fb6fa1224..47a998ccae 100644
--- a/sapi/phpdbg/tests/run-tests.php
+++ b/sapi/phpdbg/tests/run-tests.php
@@ -284,6 +284,8 @@ namespace phpdbg\testing {
$test->purpose,
$result ? "PASS" : "FAIL",
PHP_EOL);
+
+ return $result;
}
protected $config;
@@ -426,7 +428,7 @@ namespace phpdbg\testing {
*/
public function getResult() {
$options = sprintf(
- '-i%s -qb', $this->file);
+ '-i%s -nqb', $this->file);
if ($this->options) {
$options = sprintf(
@@ -492,13 +494,18 @@ namespace phpdbg\testing {
*
*/
protected function writeDiff() {
- $diff = sprintf(
- '%s/%s.diff',
- dirname($this->file), basename($this->file));
-
if (count($this->diff['wants'])) {
- if (!in_array('nodiff', $this->config['flags'])) {
- if (($diff = fopen($diff, 'w+'))) {
+ if (!$this->config->hasFlag('nodiff')) {
+ if ($this->config->hasFlag('diff2stdout')) {
+ $difffile = "php://stdout";
+ file_put_contents($difffile, "====DIFF====\n");
+ } else {
+ $difffile = sprintf(
+ '%s/%s.diff',
+ dirname($this->file), basename($this->file));
+ }
+
+ if (($diff = fopen($difffile, 'w+'))) {
foreach ($this->diff['wants'] as $line => $want) {
$got = $this->diff['gets'][$line];
@@ -552,6 +559,9 @@ namespace {
$cwd = dirname(__FILE__);
$cmd = $_SERVER['argv'];
+
+ $retval = 0;
+
{
$config = new TestsConfiguration(array(
'exec' => realpath(array_shift($cmd)),
@@ -571,7 +581,7 @@ namespace {
$tests->logPath($path);
foreach ($tests->findTests($path) as $test) {
- $tests->logTest($path, $test);
+ $retval |= !$tests->logTest($path, $test);
}
$tests->logPathStats($path);
@@ -579,5 +589,7 @@ namespace {
$tests->logStats();
}
+
+ die($retval);
}
?>