Skip to content

Commit e6dbf0e

Browse files
committed
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
* 'PHP-5.5' of git.php.net:php-src: Use zend_error_noreturn here Add Tests for #65784 in 5.5 Disallowed JMP into a finally block. Update NEWS for 5.5.7 release
2 parents 711d8c2 + ef73f85 commit e6dbf0e

File tree

3 files changed

+78
-6
lines changed

3 files changed

+78
-6
lines changed

NEWS

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2013, PHP 5.5.8
44

55
- Core:
6+
. Disallowed JMP into a finally block. (Laruence)
67
. Added validation of class names in the autoload process. (Dmitry)
78
. Fixed invalid C code in zend_strtod.c. (Lior Kaplan)
89
. Fixed bug #66041 (list() fails to unpack yielded ArrayAccess object).
@@ -41,7 +42,7 @@ PHP NEWS
4142
. Fixed bug #49634 (Segfault throwing an exception in a XSL registered
4243
function). (Mike)
4344

44-
?? ??? 2013, PHP 5.5.7
45+
12 Dec 2013, PHP 5.5.7
4546

4647
- CLI server:
4748
. Added some MIME types to the CLI web server (Chris Jones)
@@ -62,6 +63,10 @@ PHP NEWS
6263
- readline
6364
. Fixed Bug #65714 (PHP cli forces the tty to cooked mode). (Remi)
6465

66+
- Openssl:
67+
. Fixed memory corruption in openssl_x509_parse() (CVE-2013-6420).
68+
(Stefan Esser).
69+
6570
14 Nov 2013, PHP 5.5.6
6671

6772
- Core:

Zend/tests/bug65784.phpt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
Fixed Bug #65784 (Segfault with finally)
3+
--XFAIL--
4+
This bug is not fixed in 5.5 due to ABI BC
5+
--FILE--
6+
<?php
7+
function foo1() {
8+
try {
9+
throw new Exception("not catch");
10+
return true;
11+
} finally {
12+
try {
13+
throw new Exception("catched");
14+
} catch (Exception $e) {
15+
}
16+
}
17+
}
18+
try {
19+
$foo = foo1();
20+
var_dump($foo);
21+
} catch (Exception $e) {
22+
do {
23+
var_dump($e->getMessage());
24+
} while ($e = $e->getPrevious());
25+
}
26+
27+
function foo2() {
28+
try {
29+
try {
30+
throw new Exception("catched");
31+
return true;
32+
} finally {
33+
try {
34+
throw new Exception("catched");
35+
} catch (Exception $e) {
36+
}
37+
}
38+
} catch (Exception $e) {
39+
}
40+
}
41+
42+
$foo = foo2();
43+
var_dump($foo);
44+
45+
function foo3() {
46+
try {
47+
throw new Exception("not catched");
48+
return true;
49+
} finally {
50+
try {
51+
throw new NotExists();
52+
} catch (Exception $e) {
53+
}
54+
}
55+
}
56+
57+
$bar = foo3();
58+
--EXPECTF--
59+
string(9) "not catch"
60+
NULL
61+
62+
Fatal error: Class 'NotExists' not found in %sbug65784.php on line %d

Zend/zend_opcode.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,22 @@ static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_nu
489489
zend_uint i;
490490

491491
for (i = 0; i < op_array->last_try_catch; i++) {
492-
if (op_array->try_catch_array[i].try_op > op_num) {
493-
break;
494-
}
495-
if ((op_num >= op_array->try_catch_array[i].finally_op
492+
if ((op_num < op_array->try_catch_array[i].finally_op ||
493+
op_num >= op_array->try_catch_array[i].finally_end)
494+
&& (dst_num >= op_array->try_catch_array[i].finally_op &&
495+
dst_num <= op_array->try_catch_array[i].finally_end)) {
496+
CG(in_compilation) = 1;
497+
CG(active_op_array) = op_array;
498+
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
499+
zend_error_noreturn(E_COMPILE_ERROR, "jump into a finally block is disallowed");
500+
} else if ((op_num >= op_array->try_catch_array[i].finally_op
496501
&& op_num <= op_array->try_catch_array[i].finally_end)
497502
&& (dst_num > op_array->try_catch_array[i].finally_end
498503
|| dst_num < op_array->try_catch_array[i].finally_op)) {
499504
CG(in_compilation) = 1;
500505
CG(active_op_array) = op_array;
501506
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
502-
zend_error(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
507+
zend_error_noreturn(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
503508
}
504509
}
505510
}

0 commit comments

Comments
 (0)