Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make static analyzers happy

  • Loading branch information...
commit 1488704098d253fa022c2711ba4f98f753666c68 1 parent d091516
Ilia Alshanetsky authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 ext/phar/phar_object.c
23 ext/phar/phar_object.c
View
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.