From b5b258c9f424673d6670e05add63d84430bcb461 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 4 Jun 2025 14:20:37 +0200 Subject: [PATCH] [winpr,path] fix NULL arguments for DeleteFile --- server/shadow/shadow_server.c | 2 +- winpr/libwinpr/path/shell.c | 14 ++++++-------- winpr/tools/makecert/makecert.c | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 9cbddb017..29765737b 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -914,7 +914,7 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server) if (!winpr_PathFileExists(filepath) && !winpr_PathMakePath(filepath, 0)) { - if (!CreateDirectoryA(filepath, 0)) + if (!winpr_PathMakePath(filepath, NULL)) { WLog_ERR(TAG, "Failed to create directory '%s'", filepath); goto out_fail; diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index 2a659f140..db8aeccc4 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -760,11 +760,10 @@ BOOL winpr_DeleteFile(const char* lpFileName) BOOL result = FALSE; if (lpFileName) - { lpFileNameW = ConvertUtf8ToWCharAlloc(lpFileName, NULL); - if (!lpFileNameW) - goto cleanup; - } + + if (!lpFileNameW) + goto cleanup; result = DeleteFileW(lpFileNameW); @@ -783,11 +782,10 @@ BOOL winpr_RemoveDirectory(LPCSTR lpPathName) BOOL result = FALSE; if (lpPathName) - { lpPathNameW = ConvertUtf8ToWCharAlloc(lpPathName, NULL); - if (!lpPathNameW) - goto cleanup; - } + + if (!lpPathNameW) + goto cleanup; result = RemoveDirectoryW(lpPathNameW); diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c index ac3555d76..15a2d16c8 100644 --- a/winpr/tools/makecert/makecert.c +++ b/winpr/tools/makecert/makecert.c @@ -1102,7 +1102,7 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv) { if (!winpr_PathFileExists(context->output_path)) { - if (!CreateDirectoryA(context->output_path, NULL)) + if (!winpr_PathMakePath(context->output_path, NULL)) return -1; }