Skip to content

Commit 11a288b

Browse files
committed
fabrics: Fix uuid_from_dmi_entries() read buffer initialization
Valgrind complaining about accessing uninitialized memory: ==159962== Conditional jump or move depends on uninitialised value(s) ==159962== at 0x484BCF6: rawmemchr (vg_replace_strmem.c:1564) ==159962== by 0x4F52B15: _IO_str_init_static_internal (strops.c:41) ==159962== by 0x4F1DAB1: UnknownInlinedFun (strfile.h:95) ==159962== by 0x4F1DAB1: __isoc99_sscanf (isoc99_sscanf.c:28) ==159962== by 0x7B77C97: uuid_from_dmi_entries (fabrics.c:969) ==159962== by 0x7B84192: UnknownInlinedFun (fabrics.c:1059) ==159962== by 0x7B84192: nvmf_hostnqn_generate (fabrics.c:1070)
1 parent a354a2d commit 11a288b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/nvme/fabrics.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int uuid_from_dmi_entries(char *system_uuid)
946946
int f;
947947
DIR *d;
948948
struct dirent *de;
949-
char buf[512];
949+
char buf[512] = {0};
950950

951951
system_uuid[0] = '\0';
952952
d = opendir(PATH_DMI_ENTRIES);
@@ -964,7 +964,7 @@ static int uuid_from_dmi_entries(char *system_uuid)
964964
continue;
965965
len = read(f, buf, 512);
966966
close(f);
967-
if (len < 0)
967+
if (len <= 0)
968968
continue;
969969
if (sscanf(buf, "%d", &type) != 1)
970970
continue;
@@ -976,7 +976,7 @@ static int uuid_from_dmi_entries(char *system_uuid)
976976
continue;
977977
len = read(f, buf, 512);
978978
close(f);
979-
if (len < 0)
979+
if (len <= 0)
980980
continue;
981981
/* Sigh. https://en.wikipedia.org/wiki/Overengineering */
982982
/* DMTF SMBIOS 3.0 Section 7.2.1 System UUID */

0 commit comments

Comments
 (0)