diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2011-08-09 14:11:56 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2011-08-09 14:11:56 +0000 |
commit | 1488704098d253fa022c2711ba4f98f753666c68 (patch) | |
tree | 11fe6ee432dccefffdbffefa09c91c399db3ad82 | |
parent | d091516c31801dadfec242a65a2859f38cd1e08b (diff) | |
download | php-git-1488704098d253fa022c2711ba4f98f753666c68.tar.gz |
Make static analyzers happy
-rw-r--r-- | ext/phar/phar_object.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 01c9cc2e30..305eb9c7de 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1664,11 +1664,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ } test = expand_filepath(fname, NULL TSRMLS_CC); + efree(fname); if (test) { - efree(fname); fname = test; fname_len = strlen(fname); + } else { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + return ZEND_HASH_APPLY_STOP; } save = fname; @@ -1694,6 +1697,11 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ #else fname = expand_filepath(intern->file_name, NULL TSRMLS_CC); #endif + if (!fname) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + return ZEND_HASH_APPLY_STOP; + } + fname_len = strlen(fname); save = fname; goto phar_spl_fileinfo; @@ -1711,6 +1719,14 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ phar_spl_fileinfo: if (base_len) { temp = expand_filepath(base, NULL TSRMLS_CC); + if (!temp) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); + if (save) { + efree(save); + } + return ZEND_HASH_APPLY_STOP; + } + base = temp; base_len = strlen(base); @@ -4083,7 +4099,10 @@ PHP_METHOD(Phar, getStub) if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) { fp = phar_obj->arc.archive->fp; } else { - fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL); + if (!(fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL))) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "phar error: unable to open phar \"%s\"", phar_obj->arc.archive->fname); + return; + } if (stub->flags & PHAR_ENT_COMPRESSION_MASK) { char *filter_name; |