Commit:    9bfd55cda3bd66b56af84a569fafd8a77cbb3726
Author:    Michael Wallner <m...@php.net>         Wed, 18 Sep 2013 11:10:55 
+0200
Parents:   dfd7d1063a5292b04f6134284337550f4f513749
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=9bfd55cda3bd66b56af84a569fafd8a77cbb3726

Log:
fix a very rare case of use of uninitialized value combined with a
memleak

Changed paths:
  M  main/fopen_wrappers.c


Diff:
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 6f11cf3..9b8645a 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 {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to