From ab18f8f2228bf1019bf310923ebf55c36149efa4 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 23 Aug 2018 10:04:26 +0200 Subject: [PATCH] Fix #4680: Return proper directory name. --- channels/drive/client/drive_file.c | 4 ++-- winpr/libwinpr/file/generic.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 2989c8d24..6049278e3 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -53,8 +53,8 @@ static void drive_file_fix_path(WCHAR* path) { - int i; - int length; + size_t i; + size_t length; length = (int) _wcslen(path); for (i = 0; i < length; i++) diff --git a/winpr/libwinpr/file/generic.c b/winpr/libwinpr/file/generic.c index 57b338e93..ca5699e5a 100644 --- a/winpr/libwinpr/file/generic.c +++ b/winpr/libwinpr/file/generic.c @@ -933,7 +933,22 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) } if (FindNextFileA((HANDLE) pFileSearch, lpFindFileData)) + { + if (isDir) + { + char* name = strrchr(lpFileName, '/'); + + if (!name) + name = lpFileName; + else + name++; + + pFileSearch->lpPattern[0] = '*'; + strcpy(lpFindFileData->cFileName, name); + } + return (HANDLE) pFileSearch; + } FindClose(pFileSearch); return INVALID_HANDLE_VALUE;