Skip to content

Commit de57850

Browse files
committed
Fix parsing of semi-reserved tokens at offset > 4GB
Related to GH-5668 Also affects php 8.0 but this changes the datastructures in public header files. (binary ABI change) PHP 7.4 wouldn't even parse a class with the below example. 1. Fix parsing semi-reserved tokens such as `namespace` with an offset that's larger than 2**32 2. Fix parsing some tokens when their length is larger than 2**32 Offset is relative to yy_start(the start of the file?) Low priority because 4GB php files are extremely rare ``` php > ini_set('memory_limit', '12G'); php > eval(str_repeat(' ' , 2**32) . 'class MyClass{ public static function namespace() {}}'); php > MyClass::namespace(); Warning: Uncaught Error: Call to undefined method MyClass::namespace() in php shell code:1 Stack trace: thrown in php shell code on line 1 php > var_export((new ReflectionClass('MyClass'))->getMethods()); array ( 0 => ReflectionMethod::__set_state(array( 'name' => ' ', 'class' => 'MyClass', )), ) ```
1 parent f0d6151 commit de57850

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Zend/zend_compile.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ typedef struct _zend_file_context {
118118
} zend_file_context;
119119

120120
typedef struct {
121-
uint32_t offset;
121+
/* Offset in bytes relative to the file start */
122+
size_t offset;
123+
/* This uses 32-bit integers to avoid doubling the size of the parser stack elements. */
122124
uint32_t len;
123125
} zend_lexer_ident_ref;
124126

0 commit comments

Comments
 (0)