Skip to content

NULL deref in spl_directory.c #17225

Closed
Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$fname = __DIR__ . '/gh14687.phar.zip';
$phar = new Phar($fname);
class HasDestructor {
public function __destruct() {
var_dump($GLOBALS['s']);
}
}
$s = new SplObjectStorage();
$s[$phar] = new HasDestructor();
register_shutdown_function(function() {
global $s;
});
$fusion = $phar;
if ($fusion->isLink()) {
}

Resulted in this output:

/home/phpfuzz/WorkSpace/flowfusion/php-src/ext/spl/spl_directory.c:209:36: runtime error: member access within null pointer of type 'php_stream' (aka 'struct _php_stream')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/phpfuzz/WorkSpace/flowfusion/php-src/ext/spl/spl_directory.c:209:36

To reproduce:

-d "phar.readonly=0"

PHP Version

nightly

Operating System

No response

Activity

  1. ndossche commented on Dec 20, 2024

    @ndossche
    Member

    I have a strong déjà vu with this one. Might try to analyze this tomorrow if someone else doesn't beat me to it.

  2. self-assigned this
    on Dec 21, 2024
  3. ndossche commented on Dec 21, 2024

    @ndossche
    Member

    This is extremely similar to GH-14687, fix may've been incomplete.

  4. changed the title [-]SEGV ext/spl/spl_directory.c:209[/-] [+]NULL deref in spl_directory.c[/+] on Dec 21, 2024
  5. added a commit that references this issue on Dec 21, 2024
    2474759
  6. added 2 commits that reference this issue on Dec 21, 2024
    4bfe69b
    a026480
  7. added a commit that references this issue on Dec 21, 2024
    8d39261
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