diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index d75d7ac37..d99eaeed2 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -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; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 97a27323c..79a506ec0 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -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;