]> granicus.if.org Git - php/commitdiff
- We forgot to check that the phar exists before trying to extract files from it :)
authorSteph Fox <sfox@php.net>
Mon, 7 Jul 2008 01:11:07 +0000 (01:11 +0000)
committerSteph Fox <sfox@php.net>
Mon, 7 Jul 2008 01:11:07 +0000 (01:11 +0000)
ext/phar/phar_object.c

index 6e7b3e0bc48fb2d6c7e116fb0e652a0bdaff0e20..6723a9daccd06d90319c61520c9d44cb7b91aa8d 100755 (executable)
@@ -3868,9 +3868,10 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *
 PHP_METHOD(Phar, extractTo)
 {
        char *error = NULL;
+       php_stream *fp;
        php_stream_statbuf ssb;
        phar_entry_info *entry;
-       char *pathto, *filename;
+       char *pathto, *filename, *actual;
        int pathto_len, filename_len;
        int ret, i;
        int nelems;
@@ -3882,6 +3883,15 @@ PHP_METHOD(Phar, extractTo)
                return;
        }
 
+       fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual);
+       efree(actual);
+       if (!fp) {
+               zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
+                       "Invalid argument, %s cannot be found", phar_obj->arc.archive->fname);
+               return;
+       }
+       php_stream_close(fp);
+
        if (pathto_len < 1) {
                zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,
                        "Invalid argument, extraction path must be non-zero length");