dll: fuse: correct error handling when name exceeds limit

Related to b62e1e920b292c4928395db89e96fada29dd7c38
This commit is contained in:
zeho11 2022-12-12 12:08:48 +09:00 committed by GitHub
parent 46054c03fe
commit e550e261f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1949,18 +1949,16 @@ int fsp_fuse_intf_AddDirInfo(void *buf, const char *name,
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)
{ {
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name, if (ERROR_INSUFFICIENT_BUFFER == GetLastError())
"MultiByteToWideChar failed");
return 0;
}
else if (255 == SizeW)
{
if (255 < MultiByteToWideChar(CP_UTF8, 0, name, SizeA, NULL, 0))
{ {
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name, fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name,
"too long"); "too long");
return 0; return 0;
} }
fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name,
"MultiByteToWideChar failed");
return 0;
} }
memset(DirInfo, 0, sizeof *DirInfo); memset(DirInfo, 0, sizeof *DirInfo);