summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-06-04 16:27:45 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-06-04 16:27:57 +0200
commitd154301866a0afaae5a70677637490b3a3b5c62e (patch)
tree845325e716da80f8c0091844e2f7fe483e8e8705
parenta4633b13d4dc33c067159192a0e0f146e03f8738 (diff)
parenta3e6b50442db106d354931ecaa0284a200609be6 (diff)
downloadphp-git-d154301866a0afaae5a70677637490b3a3b5c62e.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
-rw-r--r--NEWS4
-rw-r--r--sapi/phpdbg/phpdbg_list.c34
2 files changed, 21 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index 14ab328f96..65a2d67e73 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,10 @@ PHP NEWS
. Fixed bug #78079 (openssl_encrypt_ccm.phpt fails with OpenSSL 1.1.1c).
(Jakub Zelenka)
+- phpdbg:
+ . Fixed bug #78050 (SegFault phpdbg + opcache on include file twice).
+ (Nikita)
+
- Sockets:
. Fixed bug #78038 (Socket_select fails when resource array contains
references). (Nikita)
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 15d1313e99..aab641cb56 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -237,29 +237,29 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
zend_op_array *ret;
uint32_t line;
char *bufptr, *endptr;
- int size;
+ size_t len;
+
+ /* Copy file contents before calling original compile_file,
+ * as it may invalidate the file handle. */
+ if (zend_stream_fixup(file, &bufptr, &len) == FAILURE) {
+ if (type == ZEND_REQUIRE) {
+ zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file->filename);
+ zend_bailout();
+ } else {
+ zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file->filename);
+ }
+ }
+
+ data.buf = estrndup(bufptr, len);
+ data.len = len;
ret = PHPDBG_G(compile_file)(file, type);
if (ret == NULL) {
+ efree(data.buf);
return ret;
}
- if (file->type == ZEND_HANDLE_MAPPED) {
- data.len = file->handle.stream.mmap.len;
- data.buf = emalloc(data.len + 1);
- memcpy(data.buf, file->handle.stream.mmap.buf, data.len);
- } else {
- if (file->type == ZEND_HANDLE_FILENAME) {
- zend_stream_open(file->filename, file);
- }
-
- size = file->handle.stream.fsizer(file->handle.stream.handle);
- data.buf = emalloc(size + 1);
- data.len = file->handle.stream.reader(file->handle.stream.handle, data.buf, size);
- }
-
- memset(data.buf + data.len, 0, 1);
-
+ data.buf[data.len] = '\0';
data.line[0] = 0;
*(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint32_t) * data.len)) = data;