From 4b5079f4b76e407c212e8931dcb255563889848b Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Mon, 14 Apr 2008 15:46:06 +0000 Subject: [PATCH] increase test coverage of phar_wrapper_mkdir, fix segfault when mkdir() on existing directory --- ext/phar/dirstream.c | 2 -- ext/phar/tests/dir.phpt | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 5da223ade1..c4f1ec3c79 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -458,8 +458,6 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in if ((e = phar_get_entry_info_dir(phar, resource->path + 1, strlen(resource->path + 1), 2, &error TSRMLS_CC))) { /* directory exists, or is a subdirectory of an existing file */ - efree(e->filename); - efree(e); php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", resource->path+1, resource->host); php_url_free(resource); return FAILURE; diff --git a/ext/phar/tests/dir.phpt b/ext/phar/tests/dir.phpt index 2aa8880e3e..578e2df012 100644 --- a/ext/phar/tests/dir.phpt +++ b/ext/phar/tests/dir.phpt @@ -33,11 +33,15 @@ mkdir($pname . '/fails'); ini_set('phar.readonly', 0); // create new phar by mkdir mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails'); +mkdir('phar://' . dirname(__FILE__) . '/ok.phar/fails'); +file_put_contents(dirname(__FILE__) . '/oops.phar', ' ===DONE=== --CLEAN-- + --EXPECTF-- @@ -50,4 +54,8 @@ bool(true) bool(false) Warning: mkdir(): phar error: cannot create directory "phar://%sdir.phar.php/fails", write operations disabled in %sdir.php on line %d + +Warning: mkdir(): phar error: cannot create directory "fails" in phar "%sok.phar", directory already exists in %sdir.php on line %d + +Warning: mkdir(): internal corruption of phar "%soops.phar" (truncated manifest at stub end) in %sdir.php on line %d ===DONE=== \ No newline at end of file -- 2.40.0