Skip to content

Commit fa59cc2

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: fix zpp fix zpp Escape non-printable characters in the junit XML output Fixed broken XML junit output due to escaping of CDATA sections Fix #50444: PDO-ODBC changes for 64-bit update NEWS backport this piece from 5.6, related to the #66307 fix Fixed bug #66307 Fileinfo crashes with powerpoint files Fix bug #67328 (fileinfo: numerous file_printf calls resulting in performance degradation) Fix bug #67327: fileinfo: CDF infinite loop in nelements DoS fix my last commit with some locales fix my last commit with some locales Update NEWs and add a test
2 parents 567f5e5 + 4796204 commit fa59cc2

File tree

6 files changed

+51
-24
lines changed

6 files changed

+51
-24
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 | 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 -h | sed -e 's/ZZZZ/.libs/g' | uniq` ;\
1818
for x in $$files; do \
1919
echo -n . ;\
2020
y=`echo $$x | sed -e 's!\.libs/!!'`; \

ext/fileinfo/libmagic/cdf.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,10 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
823823
i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
824824
if (inp[i].pi_type & CDF_VECTOR) {
825825
nelements = CDF_GETUINT32(q, 1);
826+
if (nelements == 0) {
827+
DPRINTF(("CDF_VECTOR with nelements == 0\n"));
828+
goto out;
829+
}
826830
o = 2;
827831
} else {
828832
nelements = 1;
@@ -897,7 +901,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
897901
}
898902
DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
899903
nelements));
900-
for (j = 0; j < nelements; j++, i++) {
904+
for (j = 0; j < nelements && i < sh.sh_properties;
905+
j++, i++)
906+
{
901907
uint32_t l = CDF_GETUINT32(q, o);
902908
inp[i].pi_str.s_len = l;
903909
inp[i].pi_str.s_buf = (const char *)
@@ -942,7 +948,7 @@ int
942948
cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
943949
cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
944950
{
945-
size_t i, maxcount;
951+
size_t maxcount;
946952
const cdf_summary_info_header_t *si =
947953
CAST(const cdf_summary_info_header_t *, sst->sst_tab);
948954
const cdf_section_declaration_t *sd =
@@ -957,21 +963,13 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
957963
ssi->si_os = CDF_TOLE2(si->si_os);
958964
ssi->si_class = si->si_class;
959965
cdf_swap_class(&ssi->si_class);
960-
ssi->si_count = CDF_TOLE2(si->si_count);
966+
ssi->si_count = CDF_TOLE4(si->si_count);
961967
*count = 0;
962968
maxcount = 0;
963969
*info = NULL;
964-
for (i = 0; i < CDF_TOLE4(si->si_count); i++) {
965-
if (i >= CDF_LOOP_LIMIT) {
966-
DPRINTF(("Unpack summary info loop limit"));
967-
errno = EFTYPE;
970+
if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info,
971+
count, &maxcount) == -1)
968972
return -1;
969-
}
970-
if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
971-
info, count, &maxcount) == -1) {
972-
return -1;
973-
}
974-
}
975973
return 0;
976974
}
977975

ext/opcache/tests/issue0183.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
ISSUE #183 (TMP_VAR is not only used once)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
<?php if (PHP_OS != "Linux") die("skip, only for linux"); ?>
10+
--FILE--
11+
<?php
12+
13+
switch (PHP_OS) {
14+
case "Windows":
15+
break;
16+
case "Darwin":
17+
break;
18+
case "Linux":
19+
echo "okey";
20+
break;
21+
default:
22+
break;
23+
}
24+
--EXPECT--
25+
okey

ext/phar/phar_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,10 +1940,10 @@ PHP_METHOD(Phar, buildFromIterator)
19401940
PHP_METHOD(Phar, count)
19411941
{
19421942
/* mode can be ignored, maximum depth is 1 */
1943-
long mode;
1943+
php_int_t mode;
19441944
PHAR_ARCHIVE_OBJECT();
19451945

1946-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
1946+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &mode) == FAILURE) {
19471947
RETURN_FALSE;
19481948
}
19491949

ext/sysvmsg/sysvmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ PHP_FUNCTION(msg_send)
398398

399399
RETVAL_FALSE;
400400

401-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz|bbz",
401+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "riz|bbz",
402402
&queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE) {
403403
return;
404404
}

run-tests.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ function run_test($php, $file, $env)
15361536
}
15371537

15381538
$message = !empty($m[1]) ? $m[1] : '';
1539-
junit_mark_test_as('SKIP', $shortname, $tested, null, "<![CDATA[\n$message\n]]>");
1539+
junit_mark_test_as('SKIP', $shortname, $tested, null, $message);
15401540
return 'SKIPPED';
15411541
}
15421542

@@ -1561,7 +1561,7 @@ function run_test($php, $file, $env)
15611561
) {
15621562
$message = "ext/zlib required";
15631563
show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames);
1564-
junit_mark_test_as('SKIP', $shortname, $tested, null, "<![CDATA[\n$message\n]]>");
1564+
junit_mark_test_as('SKIP', $shortname, $tested, null, $message);
15651565
return 'SKIPPED';
15661566
}
15671567

@@ -2129,7 +2129,7 @@ function run_test($php, $file, $env)
21292129
$php = $old_php;
21302130
}
21312131

2132-
$diff = empty($diff) ? '' : "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>";
2132+
$diff = empty($diff) ? '' : preg_replace('/\e/', '<esc>', $diff);
21332133

21342134
junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
21352135

@@ -2708,6 +2708,10 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
27082708
junit_suite_record($suite, 'execution_time', $time);
27092709

27102710
$escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8');
2711+
$escaped_details = preg_replace_callback('/[\0-\x08\x0B\x0C\x0E-\x1F]/', function ($c) {
2712+
return sprintf('[[0x%02x]]', ord($c[0]));
2713+
}, $escaped_details);
2714+
$escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
27112715

27122716
$escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);
27132717
$JUNIT['files'][$file_name]['xml'] = "<testcase classname='$suite' name='$escaped_test_name' time='$time'>\n";
@@ -2724,16 +2728,16 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
27242728
junit_suite_record($suite, 'test_pass');
27252729
} elseif ('BORK' == $type) {
27262730
junit_suite_record($suite, 'test_error');
2727-
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'/>\n";
2731+
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$escaped_message'/>\n";
27282732
} elseif ('SKIP' == $type) {
27292733
junit_suite_record($suite, 'test_skip');
2730-
$JUNIT['files'][$file_name]['xml'] .= "<skipped>$message</skipped>\n";
2734+
$JUNIT['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
27312735
} elseif('FAIL' == $type) {
27322736
junit_suite_record($suite, 'test_fail');
2733-
$JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$message'>$escaped_details</failure>\n";
2737+
$JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$escaped_message'>$escaped_details</failure>\n";
27342738
} else {
27352739
junit_suite_record($suite, 'test_error');
2736-
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'>$escaped_details</error>\n";
2740+
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$escaped_message'>$escaped_details</error>\n";
27372741
}
27382742

27392743
$JUNIT['files'][$file_name]['xml'] .= "</testcase>\n";

0 commit comments

Comments
 (0)