From: Greg Beaver Date: Sat, 12 Apr 2008 22:21:29 +0000 (+0000) Subject: add test for opendir, fix bugs found X-Git-Tag: RELEASE_2_0_0b1~443 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72daaf1d44dc1d3e0ce6f27f6fd0bdd948dd1305;p=php add test for opendir, fix bugs found --- diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index d12c491382..c814545464 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -51,7 +51,7 @@ PHAR_FUNC(phar_opendir) /* {{{ */ char *name; efree(entry); - entry = filename; + entry = estrndup(filename, filename_len); /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; if (strstr(entry, "://")) { @@ -70,11 +70,9 @@ PHAR_FUNC(phar_opendir) /* {{{ */ stream = php_stream_opendir(name, REPORT_ERRORS, context); efree(name); if (!stream) { - efree(entry); goto skip_phar; } php_stream_to_zval(stream, return_value); - efree(entry); return; } } diff --git a/ext/phar/tests/opendir.phpt b/ext/phar/tests/opendir.phpt new file mode 100644 index 0000000000..62dd9d6496 --- /dev/null +++ b/ext/phar/tests/opendir.phpt @@ -0,0 +1,32 @@ +--TEST-- +Phar: test opendir() interception +--SKIPIF-- + +--INI-- +phar.require_hash=1 +phar.readonly=0 +--FILE-- +'; +$a['dir/file1.txt'] = 'hi'; +$a['dir/file2.txt'] = 'hi2'; +$a['dir/file3.txt'] = 'hi3'; +$a->setStub(' +===DONE=== +--CLEAN-- + +--EXPECT-- +file1.txtfile2.txtfile3.txt===DONE=== \ No newline at end of file