summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Wallner <mike@php.net>2013-09-18 11:12:11 +0200
committerMichael Wallner <mike@php.net>2013-09-18 11:12:11 +0200
commita34b141e08f02c34a100676080dddf7d9be84544 (patch)
treeece78deeab329be3e1379de22f81cffe3eedaae3
parent5e3da04fb033734d2e69542fe835660c0df8dc48 (diff)
parent9bfd55cda3bd66b56af84a569fafd8a77cbb3726 (diff)
downloadphp-git-a34b141e08f02c34a100676080dddf7d9be84544.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: fix a very rare case of use of uninitialized value combined with a memleak
-rw-r--r--main/fopen_wrappers.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 6f11cf3f32..9b8645a061 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -775,7 +775,12 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
* we cannot cannot getcwd() and the requested,
* relatively referenced file is accessible */
copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
- real_path = estrndup(filepath, copy_len);
+ if (real_path) {
+ memcpy(real_path, filepath, copy_len);
+ real_path[copy_len] = '\0';
+ } else {
+ real_path = estrndup(filepath, copy_len);
+ }
close(fdtest);
return real_path;
} else {