From e550e261f0dd318769741579d6e185fb6e12055e Mon Sep 17 00:00:00 2001 From: zeho11 <73569575+zeho11@users.noreply.github.com> Date: Mon, 12 Dec 2022 12:08:48 +0900 Subject: [PATCH] dll: fuse: correct error handling when name exceeds limit Related to b62e1e920b292c4928395db89e96fada29dd7c38 --- src/dll/fuse/fuse_intf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/dll/fuse/fuse_intf.c b/src/dll/fuse/fuse_intf.c index 287f2e48..bca425d0 100644 --- a/src/dll/fuse/fuse_intf.c +++ b/src/dll/fuse/fuse_intf.c @@ -1949,18 +1949,16 @@ int fsp_fuse_intf_AddDirInfo(void *buf, const char *name, SizeW = MultiByteToWideChar(CP_UTF8, 0, name, SizeA, DirInfo->FileNameBuf, 255); if (0 == SizeW) { - fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name, - "MultiByteToWideChar failed"); - return 0; - } - else if (255 == SizeW) - { - if (255 < MultiByteToWideChar(CP_UTF8, 0, name, SizeA, NULL, 0)) + if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) { fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name, "too long"); return 0; } + + fsp_fuse_intf_LogBadDirInfo(filedesc->PosixPath, name, + "MultiByteToWideChar failed"); + return 0; } memset(DirInfo, 0, sizeof *DirInfo);