summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_list.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-07-25 19:50:31 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-07-25 19:50:31 +0200
commit66fd52939beed9f2ed367cc380f35fc13af4e66d (patch)
tree158d36891b90f3f6e9c4db1847810e4acfefc39b /sapi/phpdbg/phpdbg_list.c
parentcdde4c51e10533ad38cb79667d481d5bce079e1c (diff)
downloadphp-git-66fd52939beed9f2ed367cc380f35fc13af4e66d.tar.gz
Just always copy the buffer, that makes it much safer
At least compared to conditionally using the mmap()ped input
Diffstat (limited to 'sapi/phpdbg/phpdbg_list.c')
-rw-r--r--sapi/phpdbg/phpdbg_list.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 3559517c3e..e577333837 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -240,24 +240,16 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
char *bufptr, *endptr;
char resolved_path_buf[MAXPATHLEN];
- if (zend_stream_fixup(file, &data.buf, &data.len) == FAILURE) {
+ if (zend_stream_fixup(file, &bufptr, &data.len) == FAILURE) {
return NULL;
}
+ data.buf = emalloc(data.len + 1);
+ memcpy(data.buf, bufptr, data.len);
+ data.buf[data.len] = 0;
data.filename = filename;
data.line[0] = 0;
- if (file->handle.stream.mmap.old_closer) {
- /* do not unmap */
- file->handle.stream.closer = file->handle.stream.mmap.old_closer;
- }
-
-#if HAVE_MMAP
- if (file->type == ZEND_HANDLE_MAPPED) {
- data.map = file->handle.stream.handle;
- }
-#endif
-
fake.type = ZEND_HANDLE_MAPPED;
fake.handle.stream.mmap.buf = data.buf;
fake.handle.stream.mmap.len = data.len;
@@ -282,6 +274,7 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
ret = PHPDBG_G(compile_file)(&fake, type);
if (ret == NULL) {
+ efree(data.buf);
efree(dataptr);
return NULL;
}
@@ -333,11 +326,6 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
void phpdbg_free_file_source(zval *zv) {
phpdbg_file_source *data = Z_PTR_P(zv);
-#if HAVE_MMAP
- if (data->map) {
- php_stream_mmap_unmap(data->map);
- } else
-#endif
if (data->buf) {
efree(data->buf);
}