Skip to content

Commit fc1127b

Browse files
dwsuseigaw
authored andcommitted
fabrics: Filter out invalid UUIDs from DMI
Qemu might not initialize the system DMI correctly and nvme-cli would generate an invalid hostid. Signed-off-by: Daniel Wagner <[email protected]>
1 parent e84011e commit fc1127b

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/nvme/fabrics.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,25 @@ static int uuid_from_device_tree(char *system_uuid)
10181018
*/
10191019
#define DMI_SYSTEM_INFORMATION 1
10201020

1021+
static bool is_dmi_uuid_valid(const char *buf, size_t len)
1022+
{
1023+
int i;
1024+
1025+
/* UUID bytes are from byte 8 to 23 */
1026+
if (len < 24)
1027+
return false;
1028+
1029+
/* Test it's a invalid UUID with all zeros */
1030+
for (i = 8; i < 24; i++) {
1031+
if (buf[i])
1032+
break;
1033+
}
1034+
if (i == 24)
1035+
return false;
1036+
1037+
return true;
1038+
}
1039+
10211040
static int uuid_from_dmi_entries(char *system_uuid)
10221041
{
10231042
int f;
@@ -1053,8 +1072,10 @@ static int uuid_from_dmi_entries(char *system_uuid)
10531072
continue;
10541073
len = read(f, buf, 512);
10551074
close(f);
1056-
if (len <= 0)
1075+
1076+
if (!is_dmi_uuid_valid(buf, len))
10571077
continue;
1078+
10581079
/* Sigh. https://en.wikipedia.org/wiki/Overengineering */
10591080
/* DMTF SMBIOS 3.0 Section 7.2.1 System UUID */
10601081
sprintf(system_uuid,

0 commit comments

Comments
 (0)