diff options
author | Stanislav Malyshev <stas@php.net> | 2018-12-29 18:25:37 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2019-01-06 11:38:46 -0800 |
commit | 78bd3477745f1ada9578a79f61edb41886bec1cb (patch) | |
tree | c19d9fd8caf7978bc1cea936d235dcd0b203633b | |
parent | 9c62b95e5e6a1ac3922a8819f2d56d8ea998d97a (diff) | |
download | php-git-78bd3477745f1ada9578a79f61edb41886bec1cb.tar.gz |
Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext)
-rw-r--r-- | ext/phar/phar.c | 2 | ||||
-rw-r--r-- | ext/phar/tests/bug77247.phpt | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 82a9ef3194..0d2173195c 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2008,7 +2008,7 @@ next_extension: } while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { - pos = memchr(pos + 1, '.', filename_len - (pos - filename) + 1); + pos = memchr(pos + 1, '.', filename_len - (pos - filename) - 1); if (!pos) { return FAILURE; } diff --git a/ext/phar/tests/bug77247.phpt b/ext/phar/tests/bug77247.phpt new file mode 100644 index 0000000000..588975f9f2 --- /dev/null +++ b/ext/phar/tests/bug77247.phpt @@ -0,0 +1,14 @@ +--TEST-- +PHP bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +--FILE-- +<?php +try { +var_dump(new Phar('a/.b', 0,'test.phar')); +} catch(UnexpectedValueException $e) { + echo "OK"; +} +?> +--EXPECT-- +OK
\ No newline at end of file |