com php-src: Add compatibility bit: win32/ioutil.c
| From: | Anatol Belski | Date: | Wed, 03 Oct 2018 19:17:52 +0000 |
| Subject: | com php-src: Add compatibility bit: win32/ioutil.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103346@lists.php.net to get a copy of this message | ||
Commit: 14628f1c5dec3401043109a3d682cb462553cd88
Author: Anatol Belski <ab@php.net> Wed, 3 Oct 2018 21:17:52 +0200
Parents: 2ebac3263ba8f2efcaab1f7ca37a652636582058
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=14628f1c5dec3401043109a3d682cb462553cd88
Log:
Add compatibility bit
readlink in PHP doesn't error on regular files.
Changed paths:
M win32/ioutil.c
Diff:
diff --git a/win32/ioutil.c b/win32/ioutil.c
index 0ca0126...5d729da 100644
--- a/win32/ioutil.c
+++ b/win32/ioutil.c
@@ -1109,6 +1109,34 @@ PW32IO ssize_t php_win32_ioutil_readlink_w(const wchar_t *path, wchar_t *buf,
si
ret = php_win32_ioutil_readlink_int(h, buf, buf_len);
+ if (ret < 0) {
+ /* BC */
+ wchar_t target[PHP_WIN32_IOUTIL_MAXPATHLEN];
+ size_t offset = 0,
+ target_len = GetFinalPathNameByHandleW(h, target, PHP_WIN32_IOUTIL_MAXPATHLEN,
VOLUME_NAME_DOS);
+
+ if(target_len >= buf_len || target_len >= PHP_WIN32_IOUTIL_MAXPATHLEN || target_len == 0) {
+ CloseHandle(h);
+ return -1;
+ }
+
+ if(target_len > 4) {
+ /* Skip first 4 characters if they are "\\?\" */
+ if(target[0] == L'\\' && target[1] == L'\\' && target[2] ==
L'?' && target[3] == L'\\') {
+ offset = 4;
+
+ /* \\?\UNC\ */
+ if (target_len > 7 && target[4] == L'U' && target[5] ==
L'N' && target[6] == L'C') {
+ offset += 2;
+ target[offset] = L'\\';
+ }
+ }
+ }
+
+ ret = target_len - offset;
+ memcpy(buf, target + offset, (ret + 1)*sizeof(wchar_t));
+ }
+
CloseHandle(h);
return ret;