Re: [ZEND-ENGINE-CVS] cvs: TSRM / tsrm_virtual_cwd.c

From: Date: Thu, 22 Dec 2005 22:14:33 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: TSRM / tsrm_virtual_cwd.c
References: 1 2 3  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4485@lists.php.net to get a copy of this message
Nuno Lopes wrote:
edink Thu Dec 22 21:32:56 2005 EDT Modified files: /TSRM tsrm_virtual_cwd.c Log: Back out a portion of the previous patch which broke win32 file functions http://cvs.php.net/viewcvs.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.75&r2=1.76&diff_format=u Index: TSRM/tsrm_virtual_cwd.c diff -u TSRM/tsrm_virtual_cwd.c:1.75 TSRM/tsrm_virtual_cwd.c:1.76 --- TSRM/tsrm_virtual_cwd.c:1.75 Tue Dec 20 14:26:55 2005 +++ TSRM/tsrm_virtual_cwd.c Thu Dec 22 21:32:56 2005 @@ -480,7 +480,7 @@ { int new_path_length; - new_path_length = GetLongPathName(path, NULL, 0); + new_path_length = GetLongPathName(path, NULL, 0) + 1; if (new_path_length == 0) { return 1; }
From http://msdn.microsoft.com/library/en-us/fileio/fs/getlongpathname.asp: "DWORD GetLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer); If the lpszLongPath buffer is too small to contain the path, the return value is the size of the buffer that is required to hold the path, including the terminating null character, in TCHARs. Therefore, if the return value is greater than cchBuffer, call the function again using a buffer size that is at least the same size as the return value. If the function fails for any other reason, the return value is 0 (zero). To get extended error information, call GetLastError." So what was wrong in the previous patch? Now its wrong, because the new_path_length will *never* be 0, so it will never enter in that 'if'. And as it already include the \0, I can't see why that '+1' is required.
It used to have +1 and it worked. The last patch removed +1 and all windows file functions broke. I reverted that bit of the last patch and all windows file functions work again. Edin
But this patch seems clearly wrong for me. If that +1 is needed, it should be done after the 'if'. Probably the problem is somewhere else, but not here. BTW, what kind of errors are you getting? I've made a simple test to file_get_contents, is_dir, is_file,.. and they all worked. (PHP was built by me with VC 2003) Maybe this is broken in VC 6?? Nuno

« previous php.zend-engine.cvs (#4485) next »