Skip to content

Commit 749922a

Browse files
authored
Merge pull request #546 from tbzatek/valgrind-fixes-1
fabrics: Fix uuid_from_dmi_entries() read buffer initialization
2 parents e3816cd + 11a288b commit 749922a

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)