|
|
af9dc8 |
Test case removed as binary patches are not supported
|
|
|
af9dc8 |
|
|
|
af9dc8 |
|
|
|
af9dc8 |
From f59b67ae50064560d7bfcdb0d6a8ab284179053c Mon Sep 17 00:00:00 2001
|
|
|
af9dc8 |
From: Stanislav Malyshev <stas@php.net>
|
|
|
af9dc8 |
Date: Tue, 14 Apr 2015 00:03:50 -0700
|
|
|
af9dc8 |
Subject: [PATCH] Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in
|
|
|
af9dc8 |
phar_set_inode)
|
|
|
af9dc8 |
|
|
|
af9dc8 |
---
|
|
|
af9dc8 |
ext/phar/phar_internal.h | 9 ++++++---
|
|
|
af9dc8 |
ext/phar/tests/bug69441.phar | Bin 0 -> 5780 bytes
|
|
|
af9dc8 |
ext/phar/tests/bug69441.phpt | 21 +++++++++++++++++++++
|
|
|
af9dc8 |
3 files changed, 27 insertions(+), 3 deletions(-)
|
|
|
af9dc8 |
create mode 100644 ext/phar/tests/bug69441.phar
|
|
|
af9dc8 |
create mode 100644 ext/phar/tests/bug69441.phpt
|
|
|
af9dc8 |
|
|
|
af9dc8 |
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
|
|
|
af9dc8 |
index fcfc864..84282d2 100644
|
|
|
af9dc8 |
--- a/ext/phar/phar_internal.h
|
|
|
af9dc8 |
+++ b/ext/phar/phar_internal.h
|
|
|
af9dc8 |
@@ -618,10 +618,13 @@ static inline void phar_set_inode(phar_entry_info *entry TSRMLS_DC) /* {{{ */
|
|
|
af9dc8 |
{
|
|
|
af9dc8 |
char tmp[MAXPATHLEN];
|
|
|
af9dc8 |
int tmp_len;
|
|
|
af9dc8 |
+ size_t len;
|
|
|
af9dc8 |
|
|
|
af9dc8 |
- tmp_len = entry->filename_len + entry->phar->fname_len;
|
|
|
af9dc8 |
- memcpy(tmp, entry->phar->fname, entry->phar->fname_len);
|
|
|
af9dc8 |
- memcpy(tmp + entry->phar->fname_len, entry->filename, entry->filename_len);
|
|
|
af9dc8 |
+ tmp_len = MIN(MAXPATHLEN, entry->filename_len + entry->phar->fname_len);
|
|
|
af9dc8 |
+ len = MIN(entry->phar->fname_len, tmp_len);
|
|
|
af9dc8 |
+ memcpy(tmp, entry->phar->fname, len);
|
|
|
af9dc8 |
+ len = MIN(tmp_len - len, entry->filename_len);
|
|
|
af9dc8 |
+ memcpy(tmp + entry->phar->fname_len, entry->filename, len);
|
|
|
af9dc8 |
entry->inode = (unsigned short)zend_get_hash_value(tmp, tmp_len);
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
/* }}} */
|
|
|
af9dc8 |
--
|
|
|
af9dc8 |
2.1.4
|
|
|
af9dc8 |
|