tools/hv: fcopy: Fix incorrect file path conversion
authorYasumasa Suenaga <yasuenag@gmail.com>
Sat, 28 Jun 2025 02:22:17 +0000 (11:22 +0900)
committerWei Liu <wei.liu@kernel.org>
Wed, 9 Jul 2025 23:01:55 +0000 (23:01 +0000)
commit0d86a8d65c1e69610bfe1a7a774f71ff111ed8c1
tree3c590608aa010647bbf7c40ed580bbd3b77d50b4
parent7b89a44b2e8c7ba548e3ad5d5155a17279625335
tools/hv: fcopy: Fix incorrect file path conversion

The hv_fcopy_uio_daemon fails to correctly handle file copy requests
from Windows hosts (e.g. via Copy-VMFile) due to wchar_t size
differences between Windows and Linux. On Linux, wchar_t is 32 bit,
whereas Windows uses 16 bit wide characters.

Fix this by ensuring that file transfers from host to Linux guest
succeed with correctly decoded file names and paths.

- Treats file name and path as __u16 arrays, not wchar_t*.
- Allocates fixed-size buffers (W_MAX_PATH) for converted strings
  instead of using malloc.
- Adds a check for target path length to prevent snprintf() buffer
  overflow.

Fixes: 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")
Signed-off-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250628022217.1514-2-yasuenag@gmail.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20250628022217.1514-2-yasuenag@gmail.com>
tools/hv/hv_fcopy_uio_daemon.c