diff --git a/base/setup/lib/utils/volutil.c b/base/setup/lib/utils/volutil.c index 153488542a045..e165003cd4f63 100644 --- a/base/setup/lib/utils/volutil.c +++ b/base/setup/lib/utils/volutil.c @@ -108,7 +108,7 @@ MountVolume( struct { FILE_FS_VOLUME_INFORMATION; - WCHAR Data[255]; + WCHAR Data[_countof(Volume->VolumeLabel)]; } LabelInfo; Status = NtQueryVolumeInformationFile(VolumeHandle, diff --git a/base/setup/lib/utils/volutil.h b/base/setup/lib/utils/volutil.h index 2763bb898444c..ef3684e9f1ce0 100644 --- a/base/setup/lib/utils/volutil.h +++ b/base/setup/lib/utils/volutil.h @@ -7,13 +7,18 @@ #pragma once +/* The maximum volume label length is 32 characters */ +#ifndef MAXIMUM_VOLUME_LABEL_LENGTH // Defined in wdm.h only +#define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) +#endif + typedef struct _VOLINFO { // WCHAR VolumeName[MAX_PATH]; ///< Name in the DOS/Win32 namespace: "\??\Volume{GUID}\" WCHAR DeviceName[MAX_PATH]; ///< NT device name: "\Device\HarddiskVolumeN" WCHAR DriveLetter; - WCHAR VolumeLabel[20]; + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR) + 1]; ///< Volume label, NUL-terminated WCHAR FileSystem[MAX_PATH+1]; // VOLUME_TYPE VolumeType;