diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-10 16:14:04 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-10 16:14:21 +0200 |
commit | 46561dab6a3602bd5f17ef8c0786f4a0f1fc1e9c (patch) | |
tree | d7b98f7a746da0dda4a28da9bdd376043d14c54b /ext/phar | |
parent | 96c84b7bc103b8515aa6b59f5f7d773a784786ec (diff) | |
download | php-git-46561dab6a3602bd5f17ef8c0786f4a0f1fc1e9c.tar.gz |
Fix leak in phar open
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/phar.c | 1 | ||||
-rw-r--r-- | ext/phar/tests/bug77396.phpt | 14 |
2 files changed, 8 insertions, 7 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c index f1155e6274..ba76a9b0e0 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1386,6 +1386,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a mydata = ecalloc(1, sizeof(phar_archive_data)); mydata->fname = expand_filepath(fname, NULL); if (mydata->fname == NULL) { + efree(mydata); return FAILURE; } fname_len = strlen(mydata->fname); diff --git a/ext/phar/tests/bug77396.phpt b/ext/phar/tests/bug77396.phpt index ede25ff81f..7dc834aa45 100644 --- a/ext/phar/tests/bug77396.phpt +++ b/ext/phar/tests/bug77396.phpt @@ -5,11 +5,11 @@ Bug #77396 Relative filename exceeding maximum path length causes null pointer d --FILE-- <?php $path = '../' . str_repeat("x", PHP_MAXPATHLEN) . '.tar'; -$phar = new PharData($path); +try { + $phar = new PharData($path); +} catch (UnexpectedValueException $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Fatal error: Uncaught UnexpectedValueException: Phar creation or opening failed in %s%ebug77396.php:%d -Stack trace: -#0 %s%ebug77396.php(%d): PharData->__construct(%s) -#1 {main} - thrown in %s%ebug77396.php on line %d +--EXPECT-- +Phar creation or opening failed |