diff --git a/winpr/libwinpr/clipboard/synthetic_file.c b/winpr/libwinpr/clipboard/synthetic_file.c index 1feb557b4..826e9e305 100644 --- a/winpr/libwinpr/clipboard/synthetic_file.c +++ b/winpr/libwinpr/clipboard/synthetic_file.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "clipboard.h" @@ -104,11 +105,7 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const goto fail; const size_t len = _wcslen(file->remote_name); - for (size_t x = 0; x < len; x++) - { - if (file->remote_name[x] == '/') - file->remote_name[x] = '\\'; - } + PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS); file->dwFileAttributes = fd.dwFileAttributes; file->ftCreationTime = fd.ftCreationTime; @@ -369,8 +366,8 @@ static BOOL add_directory_contents_to_list(wClipboard* clipboard, const WCHAR* l if (!namebuf) return FALSE; - memcpy(namebuf, local_name, len * sizeof(WCHAR)); - memcpy(&namebuf[len], wildcard, sizeof(wildcard)); + _wcsncat(namebuf, local_name, len); + _wcsncat(namebuf, wildcard, ARRAYSIZE(wildcard)); result = do_add_directory_contents_to_list(clipboard, local_name, remote_name, namebuf, files);