Skip to content

Member access within null pointer of type 'ps_files' in ext/session/mod_files.c #13856

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
class CustomReadHandler extends \SessionHandler {
    public function read($session_id): string|false {
        return parent::read('mycustomsession');
    }
}
ob_start();
session_set_save_handler(new CustomReadHandler(), true);
session_start();
?>

Resulted in this output:

/php-src/ext/session/mod_files.c:140:12: runtime error: member access within null pointer of type 'ps_files'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/session/mod_files.c:140:12 in

To reproduce:

/php-src/sapi/cli/php  -n -c '/php-src/tmp-php.ini'   -d "opcache.cache_id=worker20" -d "output_handler=" -d "open_basedir=." -d "disable_functions=" -d "output_buffering=Off" -d "error_reporting=32767" -d "display_errors=1" -d "display_startup_errors=1" -d "log_errors=0" -d "html_errors=0" -d "track_errors=0" -d "report_memleaks=1" -d "report_zend_debug=0" -d "docref_root=" -d "docref_ext=.html" -d "error_prepend_string=" -d "error_append_string=" -d "auto_prepend_file=" -d "auto_append_file=" -d "ignore_repeated_errors=0" -d "precision=14" -d "serialize_precision=-1" -d "memory_limit=128M" -d "opcache.fast_shutdown=0" -d "opcache.file_update_protection=0" -d "opcache.revalidate_freq=0" -d "opcache.jit_hot_loop=1" -d "opcache.jit_hot_func=1" -d "opcache.jit_hot_return=1" -d "opcache.jit_hot_side_exit=1" -d "opcache.jit_max_root_traces=100000" -d "opcache.jit_max_side_traces=100000" -d "opcache.jit_max_exit_counters=100000" -d "opcache.protect_memory=1" -d "zend.assertions=1" -d "zend.exception_ignore_args=0" -d "zend.exception_string_param_max_len=15" -d "short_open_tag=0" -d "extension_dir=/php-src/modules/" -d "zend_extension=/php-src/modules/opcache.so" -d "session.auto_start=0" -d "session.save_handler=files" -d "session.save_path=" -d "session.use_strict_mode=0" -f "/php-src/tests/test.php"  2>&1

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Activity

  1. ndossche commented on Apr 1, 2024

    @ndossche
    Member

    Thanks again!
    Minimal repro: ./sapi/cli/php -d "open_basedir=." -d "session.save_handler=files" -f "session.php", so this is related to the open basedir restriction most likely as removing that option does not result in an error.

  2. self-assigned this
    on Apr 1, 2024
  3. added a commit that references this issue on Apr 1, 2024
    0be5634
  4. added 2 commits that reference this issue on Apr 1, 2024
    46f45a5
    3f598a3
  5. added a commit that references this issue on Apr 1, 2024
    0dc5998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions