File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17037 (UAF in user filter when adding existing filter name due to incorrect error handling)
3
+ --FILE--
4
+ <?php
5
+ var_dump (stream_filter_register ('string.toupper ' , 'filter_string_toupper ' ));
6
+ ?>
7
+ --EXPECT--
8
+ bool(false)
Original file line number Diff line number Diff line change @@ -521,13 +521,17 @@ PHP_FUNCTION(stream_filter_register)
521
521
fdat = ecalloc (1 , sizeof (struct php_user_filter_data ));
522
522
fdat -> classname = zend_string_copy (classname );
523
523
524
- if (zend_hash_add_ptr (BG (user_filter_map ), filtername , fdat ) != NULL &&
525
- php_stream_filter_register_factory_volatile (filtername , & user_filter_factory ) == SUCCESS ) {
526
- RETVAL_TRUE ;
524
+ if (zend_hash_add_ptr (BG (user_filter_map ), filtername , fdat ) != NULL ) {
525
+ if (php_stream_filter_register_factory_volatile (filtername , & user_filter_factory ) == SUCCESS ) {
526
+ RETURN_TRUE ;
527
+ }
528
+
529
+ zend_hash_del (BG (user_filter_map ), filtername );
527
530
} else {
528
531
zend_string_release_ex (classname , 0 );
529
532
efree (fdat );
530
- RETVAL_FALSE ;
531
533
}
534
+
535
+ RETURN_FALSE ;
532
536
}
533
537
/* }}} */
You can’t perform that action at this time.
0 commit comments