mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
winfsp-tests: posix_map_path_test
This commit is contained in:
parent
8c8d80add3
commit
396997fb22
@ -850,7 +850,7 @@ FSP_API NTSTATUS FspPosixMapPermissionsToSecurityDescriptor(
|
||||
FSP_API NTSTATUS FspPosixMapSecurityDescriptorToPermissions(
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||
PUINT32 PUid, PUINT32 PGid, PUINT32 PMode);
|
||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, const char **PPosixPath);
|
||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixPath);
|
||||
FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWindowsPath);
|
||||
FSP_API VOID FspPosixDeletePath(void *Path);
|
||||
|
||||
|
@ -777,7 +777,7 @@ lasterror:
|
||||
* private use area in the U+F0XX range.
|
||||
*
|
||||
* The invalid maps are produced by the following Python script:
|
||||
* reserved = ['<', '>', ':', '"', '/', '|', '?', '*']
|
||||
* reserved = ['<', '>', ':', '"', '\\', '|', '?', '*']
|
||||
* l = [str(int(0 < i < 32 or chr(i) in reserved)) for i in xrange(0, 128)]
|
||||
* print "0x%08x" % int("".join(l[0:32]), 2)
|
||||
* print "0x%08x" % int("".join(l[32:64]), 2)
|
||||
@ -787,12 +787,12 @@ lasterror:
|
||||
static UINT32 FspPosixInvalidPathChars[4] =
|
||||
{
|
||||
0x7fffffff,
|
||||
0x2021002b,
|
||||
0x00000000,
|
||||
0x2020002b,
|
||||
0x00000008,
|
||||
0x00000008,
|
||||
};
|
||||
|
||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, const char **PPosixPath)
|
||||
FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, char **PPosixPath)
|
||||
{
|
||||
NTSTATUS Result;
|
||||
ULONG Size;
|
||||
@ -817,7 +817,7 @@ FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, const char **P
|
||||
|
||||
for (p = PosixPath, q = p; *p; p++)
|
||||
{
|
||||
char c = *p;
|
||||
unsigned char c = *p;
|
||||
|
||||
if ('\\' == c)
|
||||
*q++ = '/';
|
||||
@ -826,7 +826,7 @@ FSP_API NTSTATUS FspPosixMapWindowsToPosixPath(PWSTR WindowsPath, const char **P
|
||||
{
|
||||
c = ((p[1] & 0x3) << 6) | (p[2] & 0x3f);
|
||||
if (128 > c && (FspPosixInvalidPathChars[c >> 5] & (0x80000000 >> (c & 0x1f))))
|
||||
*q++ = c;
|
||||
*q++ = c, p += 2;
|
||||
else
|
||||
*q++ = *p++, *q++ = *p++, *q++ = *p;
|
||||
}
|
||||
@ -862,7 +862,7 @@ FSP_API NTSTATUS FspPosixMapPosixToWindowsPath(const char *PosixPath, PWSTR *PWi
|
||||
if (0 == Size)
|
||||
goto lasterror;
|
||||
|
||||
WindowsPath = MemAlloc(Size);
|
||||
WindowsPath = MemAlloc(Size * sizeof(WCHAR));
|
||||
if (0 == PosixPath)
|
||||
{
|
||||
Result = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -213,8 +213,39 @@ void posix_map_sd_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
void posix_map_path_test(void)
|
||||
{
|
||||
struct
|
||||
{
|
||||
PWSTR WindowsPath;
|
||||
const char *PosixPath;
|
||||
} map[] =
|
||||
{
|
||||
{ L"\\foo\\bar", "/foo/bar" },
|
||||
{ L"\\foo\xf03c\xf03e\xf03a\xf02f\xf05c\xf022\xf07c\xf03f\xf02a\\bar", "/foo<>:\xef\x80\xaf\\\"|?*/bar" },
|
||||
};
|
||||
NTSTATUS Result;
|
||||
PWSTR WindowsPath;
|
||||
char *PosixPath;
|
||||
|
||||
for (size_t i = 0; sizeof map / sizeof map[0] > i; i++)
|
||||
{
|
||||
Result = FspPosixMapWindowsToPosixPath(map[i].WindowsPath, &PosixPath);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
ASSERT(0 == strcmp(map[i].PosixPath, PosixPath));
|
||||
|
||||
Result = FspPosixMapPosixToWindowsPath(map[i].PosixPath, &WindowsPath);
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
ASSERT(0 == wcscmp(map[i].WindowsPath, WindowsPath));
|
||||
|
||||
FspPosixDeletePath(WindowsPath);
|
||||
FspPosixDeletePath(PosixPath);
|
||||
}
|
||||
}
|
||||
|
||||
void posix_tests(void)
|
||||
{
|
||||
TEST(posix_map_sid_test);
|
||||
TEST(posix_map_sd_test);
|
||||
TEST(posix_map_path_test);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user