From 428d8164ffcf6f75a6cc9d4056e54bfd450dac03 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sat, 29 Dec 2018 18:25:37 -0800 Subject: Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) --- ext/phar/phar.c | 2 +- ext/phar/tests/bug77247.phpt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 ext/phar/tests/bug77247.phpt diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 47ff8cd790..6e5cec2462 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2017,7 +2017,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-- + +--FILE-- + +--EXPECT-- +OK \ No newline at end of file -- cgit v1.2.1