php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 0001-use-of-target_len-instead-of-MAXPATHLEN-as-buffer-si.patch for Filesystem function related Bug #69511

Patch version 2015-04-23 09:59 UTC

Return to Bug #69511 | Download this patch
Patch Revisions:

Developer: jan.starke@t-systems.com

From f5e8bf7281d75bab57e943e092c9b46c51eb7133 Mon Sep 17 00:00:00 2001
From: Jan Starke <jan.starke@outofbed.org>
Date: Thu, 23 Apr 2015 11:45:37 +0200
Subject: [PATCH] use of target_len instead of MAXPATHLEN as buffer size

---
 Zend/zend_virtual_cwd.c | 4 ++--
 main/fopen_wrappers.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index 70b4265..6713055b 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -260,8 +260,8 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
 			return -1;
 	}
 
-	dwRet = pGetFinalPathNameByHandle(hFile, target, MAXPATHLEN, VOLUME_NAME_DOS);
-	if(dwRet >= MAXPATHLEN) {
+	dwRet = pGetFinalPathNameByHandle(hFile, target, target_len, VOLUME_NAME_DOS);
+	if(dwRet >= target_len) {
 		return -1;
 	}
 
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 85127c3..fc93ac6 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -175,9 +175,9 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
 #if defined(PHP_WIN32) || defined(HAVE_SYMLINK)
 		if (nesting_level == 0) {
 			int ret;
-			char buf[MAXPATHLEN];
+			char buf[MAXPATHLEN+1];
 
-			ret = php_sys_readlink(path_tmp, buf, MAXPATHLEN - 1);
+			ret = php_sys_readlink(path_tmp, buf, (sizeof(buf)/sizeof(buf[0])) - 1);
 			if (ret < 0) {
 				/* not a broken symlink, move along.. */
 			} else {
-- 
2.3.2 (Apple Git-55)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 02:01:31 2024 UTC