Skip to content

Issue-60742: Added FilesystemIterator::OTHER_MODE_MASK - #5

Merged
dsp merged 1 commit into
php:PHP-5.4from
jaytaph:issue-60742
Mar 19, 2012
Merged

Issue-60742: Added FilesystemIterator::OTHER_MODE_MASK#5
dsp merged 1 commit into
php:PHP-5.4from
jaytaph:issue-60742

Conversation

@jaytaph

Copy link
Copy Markdown
Contributor

The FileSystemIterator defines a few constants to mask its flags: CURRENT_MODE_MASK and KEY_MODE_MASK. However, there are other flags (SKIP_DOTS and UNIX_PATHS) which cannot be masked of by a constant.

However, internally, there is a mask constant defined (SPL_FILE_DIR_OTHERS_MASK). It makes sense that this value is also known in PHP userland by the OTHER_MODE_MASK constant.

@dsp
dsp merged commit 91f2d38 into php:PHP-5.4Mar 19, 2012
weltling pushed a commit to weltling/php-src that referenced this pull request Aug 21, 2013
String size refactor take 2, partial fixes to ext/standard
@kohlerkohler mentioned this pull request Jun 12, 2020
@GXhuaGXhua mentioned this pull request Jul 31, 2020
nikic added a commit that referenced this pull request Apr 8, 2021
When encountering the following SSA graph:
BB1:
#2.T1 [string] = COALESCE #1.CV0($str) [null, string] BB2
BB2:
#5.T1 [string] = QM_ASSIGN string("")
BB3:
#7.X1 [string] = Phi(#2.X1 [string], #5.X1 [string])
FREE #7.T1 [string]
We would currently determine that #7, #5 are dead, and eliminate
the FREE and QM_ASSIGN. However, we cannot eliminate #2, as
COALESCE is also responsible for control flow.
Fix this my marking all non-CV phis as live to start with. This
can be relaxed to check the kind of the source instruction, but
I couldn't immediately come up with a case where it would be
useful.
shqking added a commit that referenced this pull request Apr 20, 2021
Part of generated opcodes for $foo are:
...
BB1:
0002 INIT_FCALL 1 96 string("foo")
0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
0005 DO_UCALL
Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.
One new path is covered in function zend_jit_send_ref() by SEND_REF
opcode.
dstogov pushed a commit that referenced this pull request Apr 29, 2021
Part of generated opcodes for $foo are:
...
BB1:
0002 INIT_FCALL 1 96 string("foo")
0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
0005 DO_UCALL
Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.
One new path is covered in function zend_jit_send_ref() by SEND_REF
opcode.
dstogov pushed a commit that referenced this pull request May 12, 2021
Part of generated opcodes for $foo are:
...
BB1:
0002 INIT_FCALL 1 96 string("foo")
0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
0005 DO_UCALL
Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.
One new path is covered in function zend_jit_send_ref() by SEND_REF
opcode.
dstogov pushed a commit that referenced this pull request May 14, 2021
Part of generated opcodes for $foo are:
...
BB1:
0002 INIT_FCALL 1 96 string("foo")
0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
0005 DO_UCALL
Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.
One new path is covered in function zend_jit_send_ref() by SEND_REF
opcode.
dstogov pushed a commit that referenced this pull request May 18, 2021
Part of generated opcodes for $foo are:
...
BB1:
0002 INIT_FCALL 1 96 string("foo")
0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
0005 DO_UCALL
Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.
One new path is covered in function zend_jit_send_ref() by SEND_REF
opcode.
@AlexeyZamorovAlexeyZamorov mentioned this pull request Aug 26, 2021
prateekbhujel added a commit to prateekbhujel/php-src that referenced this pull request May 14, 2026
wheakerd pushed a commit to wheakerd/php-src that referenced this pull request May 22, 2026
…dict
```
Direct leak of 52 byte(s) in 1 object(s) allocated from:
#0 0x7ff90cd2c161 in malloc (/usr/lib/libasan.so.8+0x12c161) (BuildId: ee5fbab73143ab257a66a33afe0f038a4af7a74e)
php#1 0x55de10c9a468 in tracked_malloc /work/php-8.4/Zend/zend_alloc.c:2973
php#2 0x55de10c99443 in _emalloc /work/php-8.4/Zend/zend_alloc.c:2740
php#3 0x55de102deb86 in zlib_create_dictionary_string /work/php-8.4/ext/zlib/zlib.c:836
php#4 0x55de102e145a in zif_deflate_init /work/php-8.4/ext/zlib/zlib.c:1144
php#5 0x55de10dcac6c in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /work/php-8.4/Zend/zend_vm_execute.h:1351
php#6 0x55de10f2d69d in execute_ex /work/php-8.4/Zend/zend_vm_execute.h:58907
php#7 0x55de10f41666 in zend_execute /work/php-8.4/Zend/zend_vm_execute.h:64334
php#8 0x55de110a6cf8 in zend_execute_script /work/php-8.4/Zend/zend.c:1934
php#9 0x55de10af0ddb in php_execute_script_ex /work/php-8.4/main/main.c:2577
php#10 0x55de10af128f in php_execute_script /work/php-8.4/main/main.c:2617
php#11 0x55de110ac5e1 in do_cli /work/php-8.4/sapi/cli/php_cli.c:935
php#12 0x55de110ae592 in main /work/php-8.4/sapi/cli/php_cli.c:1322
php#13 0x7ff90c027740 (/usr/lib/libc.so.6+0x27740) (BuildId: 020d6f7c33b2413f4fe10814c4729dce1387f049)
php#14 0x7ff90c027878 in __libc_start_main (/usr/lib/libc.so.6+0x27878) (BuildId: 020d6f7c33b2413f4fe10814c4729dce1387f049)
php#15 0x55de10005964 in _start (/work/php-8.4/sapi/cli/php+0x605964) (BuildId: 5f144db4e56ea623e070c56445fb1dfa3f8d085d)
SUMMARY: AddressSanitizer: 52 byte(s) leaked in 1 allocation(s).
```
ClosesphpGH-22101.
bukka pushed a commit that referenced this pull request Jul 1, 2026
…reset
The code tries to read the context on NULL when
`php_stream_xport_crypto_setup` fails because by then `stream` is reset
to NULL.
This is also UB, so can cause miscompiles.
```
==1217==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000090 (pc 0x55d829ed3acf bp 0x7fff045f5770 sp 0x7fff045f4df0 T0)
==1217==The signal is caused by a READ memory access.
==1217==Hint: address points to the zero page.
#0 0x55d829ed3acf in php_stream_url_wrap_http_ex /work/php-src/ext/standard/http_fopen_wrapper.c:580
#1 0x55d829ed857e in php_stream_url_wrap_http /work/php-src/ext/standard/http_fopen_wrapper.c:1204
#2 0x55d82a15073d in _php_stream_open_wrapper_ex /work/php-src/main/streams/streams.c:2270
#3 0x55d829e78fa6 in zif_file_get_contents /work/php-src/ext/standard/file.c:409
#4 0x55d829bbfe39 in zif_phar_file_get_contents /work/php-src/ext/phar/func_interceptors.c:226
#5 0x55d82a0b7ed2 in zend_test_execute_internal /work/php-src/ext/zend_test/observer.c:306
#6 0x55d82a3e024a in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER /work/php-src/Zend/zend_vm_execute.h:2154
#7 0x55d82a540995 in execute_ex /work/php-src/Zend/zend_vm_execute.h:116519
#8 0x55d82a5558b0 in zend_execute /work/php-src/Zend/zend_vm_execute.h:121962
#9 0x55d82a6ba0ab in zend_execute_script /work/php-src/Zend/zend.c:1980
#10 0x55d82a0ec8bb in php_execute_script_ex /work/php-src/main/main.c:2645
#11 0x55d82a0ecccb in php_execute_script /work/php-src/main/main.c:2685
#12 0x55d82a6bfc16 in do_cli /work/php-src/sapi/cli/php_cli.c:951
#13 0x55d82a6c21e3 in main /work/php-src/sapi/cli/php_cli.c:1362
#14 0x7f9e770491c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
#15 0x7f9e7704928a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
#16 0x55d829209b34 in _start (/work/php-src/build-dbg-asan/sapi/cli/php+0x609b34) (BuildId: aa149f943514fff0c491e1f199e30fed0e977f7c)
```
This is a backport of:
* 7782b88
* f9519cc
* afded3d
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
MaxKellermann pushed a commit to CM4all/php-src that referenced this pull request Jul 9, 2026
…reset
The code tries to read the context on NULL when
`php_stream_xport_crypto_setup` fails because by then `stream` is reset
to NULL.
This is also UB, so can cause miscompiles.
```
==1217==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000090 (pc 0x55d829ed3acf bp 0x7fff045f5770 sp 0x7fff045f4df0 T0)
==1217==The signal is caused by a READ memory access.
==1217==Hint: address points to the zero page.
#0 0x55d829ed3acf in php_stream_url_wrap_http_ex /work/php-src/ext/standard/http_fopen_wrapper.c:580
php#1 0x55d829ed857e in php_stream_url_wrap_http /work/php-src/ext/standard/http_fopen_wrapper.c:1204
php#2 0x55d82a15073d in _php_stream_open_wrapper_ex /work/php-src/main/streams/streams.c:2270
php#3 0x55d829e78fa6 in zif_file_get_contents /work/php-src/ext/standard/file.c:409
php#4 0x55d829bbfe39 in zif_phar_file_get_contents /work/php-src/ext/phar/func_interceptors.c:226
php#5 0x55d82a0b7ed2 in zend_test_execute_internal /work/php-src/ext/zend_test/observer.c:306
php#6 0x55d82a3e024a in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER /work/php-src/Zend/zend_vm_execute.h:2154
php#7 0x55d82a540995 in execute_ex /work/php-src/Zend/zend_vm_execute.h:116519
php#8 0x55d82a5558b0 in zend_execute /work/php-src/Zend/zend_vm_execute.h:121962
php#9 0x55d82a6ba0ab in zend_execute_script /work/php-src/Zend/zend.c:1980
php#10 0x55d82a0ec8bb in php_execute_script_ex /work/php-src/main/main.c:2645
php#11 0x55d82a0ecccb in php_execute_script /work/php-src/main/main.c:2685
php#12 0x55d82a6bfc16 in do_cli /work/php-src/sapi/cli/php_cli.c:951
php#13 0x55d82a6c21e3 in main /work/php-src/sapi/cli/php_cli.c:1362
php#14 0x7f9e770491c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
php#15 0x7f9e7704928a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 274eec488d230825a136fa9c4d85370fed7a0a5e)
php#16 0x55d829209b34 in _start (/work/php-src/build-dbg-asan/sapi/cli/php+0x609b34) (BuildId: aa149f943514fff0c491e1f199e30fed0e977f7c)
```
This is a backport of:
* 7782b88
* f9519cc
* afded3d
Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
This was referenced Jul 21, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jaytaph@dsp