mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
dll: fuse: correctly handle NFS_SPECFILE_LNK reparse points, which are in POSIX UTF-16 format
This commit is contained in:
parent
10635db99b
commit
cbcea380ef
@ -1195,8 +1195,20 @@ FSP_API NTSTATUS FspPosixMapPermissionsToSecurityDescriptor(
|
|||||||
FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
PUINT32 PUid, PUINT32 PGid, PUINT32 PMode);
|
PUINT32 PUid, PUINT32 PGid, PUINT32 PMode);
|
||||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixPath);
|
FSP_API NTSTATUS FspPosixMapWindowsToPosixPathEx(PWSTR WindowsPath, char **PPosixPath,
|
||||||
FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWindowsPath);
|
BOOLEAN Translate);
|
||||||
|
FSP_API NTSTATUS FspPosixMapPosixToWindowsPathEx(const char *PosixPath, PWSTR *PWindowsPath,
|
||||||
|
BOOLEAN Translate);
|
||||||
|
static inline
|
||||||
|
NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixPath)
|
||||||
|
{
|
||||||
|
return FspPosixMapWindowsToPosixPathEx(WindowsPath, PPosixPath, TRUE);
|
||||||
|
}
|
||||||
|
static inline
|
||||||
|
NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWindowsPath)
|
||||||
|
{
|
||||||
|
return FspPosixMapPosixToWindowsPathEx(PosixPath, PWindowsPath, TRUE);
|
||||||
|
}
|
||||||
FSP_API VOID FspPosixDeletePath(void *Path);
|
FSP_API VOID FspPosixDeletePath(void *Path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1999,6 +1999,7 @@ static NTSTATUS fsp_fuse_intf_SetReparsePoint(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* the PATH is in POSIX format (UTF-16 encoding) */
|
||||||
ReparseTargetPath = (PVOID)(ReparseData->GenericReparseBuffer.DataBuffer + 8);
|
ReparseTargetPath = (PVOID)(ReparseData->GenericReparseBuffer.DataBuffer + 8);
|
||||||
ReparseTargetPathLength = ReparseData->ReparseDataLength - 8;
|
ReparseTargetPathLength = ReparseData->ReparseDataLength - 8;
|
||||||
}
|
}
|
||||||
@ -2010,7 +2011,8 @@ static NTSTATUS fsp_fuse_intf_SetReparsePoint(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
* From this point forward we must jump to the EXIT label on failure.
|
* From this point forward we must jump to the EXIT label on failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Result = FspPosixMapWindowsToPosixPath(TargetPath, &PosixTargetPath);
|
Result = FspPosixMapWindowsToPosixPathEx(TargetPath, &PosixTargetPath,
|
||||||
|
IO_REPARSE_TAG_SYMLINK == ReparseData->ReparseTag);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
@ -2029,7 +2031,7 @@ static NTSTATUS fsp_fuse_intf_SetReparsePoint(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (*(PULONG)ReparseData->GenericReparseBuffer.DataBuffer)
|
switch (*(PUINT64)ReparseData->GenericReparseBuffer.DataBuffer)
|
||||||
{
|
{
|
||||||
case NFS_SPECFILE_FIFO:
|
case NFS_SPECFILE_FIFO:
|
||||||
Mode = (Mode & ~0170000) | 0010000;
|
Mode = (Mode & ~0170000) | 0010000;
|
||||||
|
@ -805,7 +805,8 @@ static UINT32 FspPosixInvalidPathChars[4] =
|
|||||||
0x00000008,
|
0x00000008,
|
||||||
};
|
};
|
||||||
|
|
||||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixPath)
|
FSP_API NTSTATUS FspPosixMapWindowsToPosixPathEx(PWSTR WindowsPath, char **PPosixPath,
|
||||||
|
BOOLEAN Translate)
|
||||||
{
|
{
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
@ -828,6 +829,8 @@ FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixP
|
|||||||
if (0 == Size)
|
if (0 == Size)
|
||||||
goto lasterror;
|
goto lasterror;
|
||||||
|
|
||||||
|
if (Translate)
|
||||||
|
{
|
||||||
for (p = PosixPath, q = p; *p; p++)
|
for (p = PosixPath, q = p; *p; p++)
|
||||||
{
|
{
|
||||||
unsigned char c = *p;
|
unsigned char c = *p;
|
||||||
@ -847,6 +850,7 @@ FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixP
|
|||||||
*q++ = c;
|
*q++ = c;
|
||||||
}
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
*PPosixPath = PosixPath;
|
*PPosixPath = PosixPath;
|
||||||
|
|
||||||
@ -863,7 +867,8 @@ lasterror:
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWindowsPath)
|
FSP_API NTSTATUS FspPosixMapPosixToWindowsPathEx(const char *PosixPath, PWSTR *PWindowsPath,
|
||||||
|
BOOLEAN Translate)
|
||||||
{
|
{
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
@ -886,6 +891,8 @@ FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWi
|
|||||||
if (0 == Size)
|
if (0 == Size)
|
||||||
goto lasterror;
|
goto lasterror;
|
||||||
|
|
||||||
|
if (Translate)
|
||||||
|
{
|
||||||
for (p = WindowsPath; *p; p++)
|
for (p = WindowsPath; *p; p++)
|
||||||
{
|
{
|
||||||
WCHAR c = *p;
|
WCHAR c = *p;
|
||||||
@ -895,6 +902,7 @@ FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWi
|
|||||||
else if (128 > c && (FspPosixInvalidPathChars[c >> 5] & (0x80000000 >> (c & 0x1f))))
|
else if (128 > c && (FspPosixInvalidPathChars[c >> 5] & (0x80000000 >> (c & 0x1f))))
|
||||||
*p |= 0xf000;
|
*p |= 0xf000;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*PWindowsPath = WindowsPath;
|
*PWindowsPath = WindowsPath;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user