Fix #3962: Remove trailing slashes from path.

This commit is contained in:
Armin Novak 2017-05-17 16:43:16 +02:00
parent 0a309fcbec
commit 6b960a4319
2 changed files with 7 additions and 3 deletions

View File

@ -181,11 +181,11 @@ static BOOL drive_file_remove_dir(const WCHAR* path)
return ret;
}
static void drive_file_set_fullpath(DRIVE_FILE* file, WCHAR* fullpath)
static void drive_file_set_fullpath(DRIVE_FILE* file, const WCHAR* fullpath)
{
free(file->fullpath);
file->fullpath = fullpath;
file->filename = _wcsrchr(file->fullpath, 0x5c);
file->filename = _wcsrchr(file->fullpath, L'/');
if (file->filename == NULL)
file->filename = file->fullpath;

View File

@ -790,6 +790,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
if (name[0] && path[0])
{
size_t pathLength = strnlen(path, PATH_MAX);
drive = (DRIVE_DEVICE*) calloc(1, sizeof(DRIVE_DEVICE));
if (!drive)
@ -816,7 +817,10 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
for (i = 0; i <= length; i++)
Stream_Write_UINT8(drive->device.data, name[i] < 0 ? '_' : name[i]);
if (ConvertToUnicode(sys_code_page, 0, path, -1, &drive->path, 0) <= 0)
if ((pathLength > 0) && (path[pathLength-1] == '/'))
pathLength --;
if (ConvertToUnicode(sys_code_page, 0, path, pathLength, &drive->path, 0) <= 0)
{
WLog_ERR(TAG, "ConvertToUnicode failed!");
error = CHANNEL_RC_NO_MEMORY;