From: Steph Fox Date: Mon, 7 Jul 2008 01:11:07 +0000 (+0000) Subject: - We forgot to check that the phar exists before trying to extract files from it :) X-Git-Tag: php-5.3.0alpha1~469 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c9df0990d16a466f4234b6e4b9048b748cb1478;p=php - We forgot to check that the phar exists before trying to extract files from it :) --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 6e7b3e0bc4..6723a9dacc 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -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");