Reviewed-by: Kostiantyn Kostiuk <[email protected]>
On Mon, Sep 7, 2026 at 1:50 PM Marc-André Lureau <
[email protected]> wrote:
> FindFirstVolumeW, FindNextVolumeW and GetVolumePathNamesForVolumeNameW
> expect a buffer length in characters, not bytes.
>
> Use ARRAYSIZE() to pass the correct character count.
>
> Fixes: b39297aedfab ("qemu-ga: Add Windows VSS provider and requester as
> DLL")
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
> qga/vss-win32/requester.cpp | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
> index b9269acb5b8e..1fd73312bab2 100644
> --- a/qga/vss-win32/requester.cpp
> +++ b/qga/vss-win32/requester.cpp
> @@ -432,7 +432,7 @@ void requester_freeze(int *num_vols, void
> *mountpoints, ErrorSet *errset)
> }
>
> if (!mountpoints) {
> - volume = FindFirstVolumeW(short_volume_name,
> sizeof(short_volume_name));
> + volume = FindFirstVolumeW(short_volume_name,
> ARRAYSIZE(short_volume_name));
> if (volume == INVALID_HANDLE_VALUE) {
> err_set(errset, hr, "failed to find first volume");
> goto out;
> @@ -447,7 +447,7 @@ void requester_freeze(int *num_vols, void
> *mountpoints, ErrorSet *errset)
> WCHAR volume_path_name[MAX_PATH];
> if (GetVolumePathNamesForVolumeNameW(
> short_volume_name, volume_path_name,
> - sizeof(volume_path_name), NULL) &&
> + ARRAYSIZE(volume_path_name), NULL) &&
> *volume_path_name) {
> display_name = volume_path_name;
> }
> @@ -459,7 +459,7 @@ void requester_freeze(int *num_vols, void
> *mountpoints, ErrorSet *errset)
> num_fixed_drives++;
> }
> if (!FindNextVolumeW(volume, short_volume_name,
> - sizeof(short_volume_name))) {
> + ARRAYSIZE(short_volume_name))) {
> FindVolumeClose(volume);
> break;
> }
>
> --
> 2.55.0.543.g5ebe2ebe4ea8
>
>