Skip to content

Close GH-9230: Consistent support for NTFS streams #9231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions win32/ioutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ typedef enum {
pathw = php_win32_ioutil_any_to_w(path); \
} while (0);

#define PHP_WIN32_IOUTIL_PATH_IS_OK_W(pathw, len) \
(!((len) >= 1 && L' ' == pathw[(len)-1] || \
(len) > 1 && !PHP_WIN32_IOUTIL_IS_SLASHW(pathw[(len)-2]) && L'.' != pathw[(len)-2] && L'.' == pathw[(len)-1]))
__forceinline static bool php_win32_ioutil_path_is_ok_w(const wchar_t *pathw, size_t len)
{
return (len < 1 || L' ' != pathw[len-1]) &&
(len <= 1 || PHP_WIN32_IOUTIL_IS_SLASHW(pathw[len-2]) || L'.' == pathw[len-2] || L'.' != pathw[len-1]);
}

#define PHP_WIN32_IOUTIL_CHECK_PATH_W(pathw, ret, dealloc) do { \
size_t _len = wcslen(pathw); \
if (!PHP_WIN32_IOUTIL_PATH_IS_OK_W(pathw, _len)) { \
if (!php_win32_ioutil_path_is_ok_w(pathw, _len)) { \
if (dealloc) { \
free((void *)pathw); \
} \
Expand Down Expand Up @@ -439,7 +441,7 @@ __forceinline static int php_win32_ioutil_rename(const char *oldnamea, const cha
return -1;
} else {
size_t newnamew_len = wcslen(newnamew);
if (!PHP_WIN32_IOUTIL_PATH_IS_OK_W(newnamew, newnamew_len)) {
if (!php_win32_ioutil_path_is_ok_w(newnamew, newnamew_len)) {
free(oldnamew);
free(newnamew);
SET_ERRNO_FROM_WIN32_CODE(ERROR_ACCESS_DENIED);
Expand Down