Skip to content

Commit 79b0425

Browse files
committed
[dev] Increase the Hardware ID buffer size
* Some (newer) SSD devices appear to have very long Hardware IDs, with tons of underscore (eg: "SCSI\DiskNVMe______________________________NVME_SSD_512GBS1111H0L") * Because of this, and because Hardware ID is a REG_SZ, where entries can be repeated many times, our static MAX_PATH buffer can be too small, preventing UAS disks from being properly listed. * Fix this by bumping our buffer to 4 KB, as well as reporting errors on Hardware ID fetch in enum debug mode. * Closes #2894.
1 parent 2fa14b0 commit 79b0425

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/dev.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ static __inline BOOL IsVHD(const char* buffer)
293293
"VMware__VMware_Virtual_S" // Enabled through a cheat mode, as this lists primary disks on VMWare instances
294294
};
295295

296-
for (i = 0; i < (int)(ARRAYSIZE(vhd_name)-(enable_vmdk?0:1)); i++)
296+
if (buffer == NULL || buffer[0] == '\0')
297+
return FALSE;
298+
for (i = 0; i < (int)(ARRAYSIZE(vhd_name) - (enable_vmdk ? 0 : 1)); i++)
297299
if (safe_strstr(buffer, vhd_name[i]) != NULL)
298300
return TRUE;
299301
return FALSE;
@@ -492,7 +494,7 @@ BOOL GetDevices(DWORD devnum)
492494
LONG maxwidth = 0;
493495
int s, u, v, score, drive_number, remove_drive, num_drives = 0;
494496
char drive_letters[27], *device_id, *devid_list = NULL, display_msg[128];
495-
char *p, *label, *display_name, buffer[MAX_PATH], str[MAX_PATH], device_instance_id[MAX_PATH], *method_str, *hub_path;
497+
char *p, *label, *display_name, buffer[4 * KB], str[MAX_PATH], device_instance_id[MAX_PATH], *method_str, *hub_path;
496498
uint32_t ignore_vid_pid[MAX_IGNORE_USB];
497499
uint64_t drive_size = 0;
498500
usb_device_props props;
@@ -663,8 +665,13 @@ BOOL GetDevices(DWORD devnum)
663665
// We can't use the friendly name to find if a drive is a VHD, as friendly name string gets translated
664666
// according to your locale, so we poke the Hardware ID
665667
memset(buffer, 0, sizeof(buffer));
666-
props.is_VHD = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID,
667-
&data_type, (LPBYTE)buffer, sizeof(buffer), &size) && IsVHD(buffer);
668+
r = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID,
669+
&data_type, (LPBYTE)buffer, sizeof(buffer), &size);
670+
// We should always be able to get a Hardware ID for disk devices, so report an error in debug if we don't
671+
if (!r && usb_debug)
672+
uprintf(" Error: %s", WindowsErrorString());
673+
props.is_VHD = IsVHD(buffer);
674+
if (!props.is_VHD)
668675
// Additional detection for SCSI card readers
669676
if ((!props.is_CARD) && (safe_strnicmp(buffer, scsi_disk_prefix, sizeof(scsi_disk_prefix)-1) == 0)) {
670677
for (j = 0; j < ARRAYSIZE(scsi_card_name); j++) {

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.12.2302"
36+
CAPTION "Rufus 4.12.2303"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -408,8 +408,8 @@ END
408408
//
409409

410410
VS_VERSION_INFO VERSIONINFO
411-
FILEVERSION 4,12,2302,0
412-
PRODUCTVERSION 4,12,2302,0
411+
FILEVERSION 4,12,2303,0
412+
PRODUCTVERSION 4,12,2303,0
413413
FILEFLAGSMASK 0x3fL
414414
#ifdef _DEBUG
415415
FILEFLAGS 0x1L
@@ -427,13 +427,13 @@ BEGIN
427427
VALUE "Comments", "https://rufus.ie"
428428
VALUE "CompanyName", "Akeo Consulting"
429429
VALUE "FileDescription", "Rufus"
430-
VALUE "FileVersion", "4.12.2302"
430+
VALUE "FileVersion", "4.12.2303"
431431
VALUE "InternalName", "Rufus"
432432
VALUE "LegalCopyright", "� 2011-2025 Pete Batard (GPL v3)"
433433
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
434434
VALUE "OriginalFilename", "rufus-4.12.exe"
435435
VALUE "ProductName", "Rufus"
436-
VALUE "ProductVersion", "4.12.2302"
436+
VALUE "ProductVersion", "4.12.2303"
437437
END
438438
END
439439
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)