mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
dll: fuse: ReadDirectory: log invalid directory entries
This commit is contained in:
parent
b4c39f656c
commit
9066338220
@ -1734,6 +1734,21 @@ exit:
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VOID fsp_fuse_intf_LogBadDirInfo(
|
||||||
|
const char *PosixPath, const char *PosixName, const char *Message)
|
||||||
|
{
|
||||||
|
static LONG Count = 0;
|
||||||
|
LONG NewCount;
|
||||||
|
|
||||||
|
NewCount = InterlockedIncrement(&Count);
|
||||||
|
|
||||||
|
/* log only the first 5 such warnings to avoid warning overload */
|
||||||
|
if (5 >= NewCount)
|
||||||
|
FspDebugLog("%S[TID=%04lx]: WARN: readdir(\"%s\"): name=\"%s\": %s\n",
|
||||||
|
FspDiagIdent(), GetCurrentThreadId(),
|
||||||
|
PosixPath, PosixName, Message);
|
||||||
|
}
|
||||||
|
|
||||||
/* !static: used by fuse2to3 */
|
/* !static: used by fuse2to3 */
|
||||||
int fsp_fuse_intf_AddDirInfo(void *buf, const char *name,
|
int fsp_fuse_intf_AddDirInfo(void *buf, const char *name,
|
||||||
const struct fuse_stat *stbuf, fuse_off_t off)
|
const struct fuse_stat *stbuf, fuse_off_t off)
|
||||||
@ -1759,13 +1774,19 @@ int fsp_fuse_intf_AddDirInfo(void *buf, const char *name,
|
|||||||
|
|
||||||
SizeA = lstrlenA(name);
|
SizeA = lstrlenA(name);
|
||||||
if (SizeA > 255)
|
if (SizeA > 255)
|
||||||
/* ignore bad filenames; should we return error code? */
|
{
|
||||||
|
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name,
|
||||||
|
"too long");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SizeW = MultiByteToWideChar(CP_UTF8, 0, name, SizeA, DirInfo->FileNameBuf, 255);
|
SizeW = MultiByteToWideChar(CP_UTF8, 0, name, SizeA, DirInfo->FileNameBuf, 255);
|
||||||
if (0 == SizeW)
|
if (0 == SizeW)
|
||||||
/* ignore bad filenames; should we return error code? */
|
{
|
||||||
|
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name,
|
||||||
|
"MultiByteToWideChar failed");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
memset(DirInfo, 0, sizeof *DirInfo);
|
memset(DirInfo, 0, sizeof *DirInfo);
|
||||||
DirInfo->Size = (UINT16)(sizeof(FSP_FSCTL_DIR_INFO) + SizeW * sizeof(WCHAR));
|
DirInfo->Size = (UINT16)(sizeof(FSP_FSCTL_DIR_INFO) + SizeW * sizeof(WCHAR));
|
||||||
@ -1866,8 +1887,12 @@ static NTSTATUS fsp_fuse_intf_FixDirInfo(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
Result = fsp_fuse_intf_GetFileInfoEx(FileSystem, PosixPath, 0,
|
Result = fsp_fuse_intf_GetFileInfoEx(FileSystem, PosixPath, 0,
|
||||||
&Uid, &Gid, &Mode, &DirInfo->FileInfo);
|
&Uid, &Gid, &Mode, &DirInfo->FileInfo);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
|
{
|
||||||
/* mark the directory buffer entry as invalid */
|
/* mark the directory buffer entry as invalid */
|
||||||
*Index = FspFileSystemDirectoryBufferEntryInvalid;
|
*Index = FspFileSystemDirectoryBufferEntryInvalid;
|
||||||
|
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, PosixName,
|
||||||
|
"getattr failed");
|
||||||
|
}
|
||||||
|
|
||||||
if (0 != PosixPathEnd)
|
if (0 != PosixPathEnd)
|
||||||
*PosixPathEnd = SavedPathChar;
|
*PosixPathEnd = SavedPathChar;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user