fabrics: check the read() return value
authorMaurizio Lombardi <mlombard@redhat.com>
Mon, 4 Mar 2024 14:05:15 +0000 (15:05 +0100)
committerDaniel Wagner <wagi@monom.org>
Tue, 5 Mar 2024 08:14:18 +0000 (09:14 +0100)
Do not pass to the is_dmi_uuid_valid() function an invalid len value
if read() fails.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
src/nvme/fabrics.c

index 1f50229f0e7ba8a8aedabe216740acff9822bdec..ac639bdfd3b9581de253384f51664df9defb63ff 100644 (file)
@@ -1297,6 +1297,8 @@ static int uuid_from_dmi_entries(char *system_uuid)
                        continue;
                len = read(f, buf, 512);
                close(f);
+               if (len <= 0)
+                       continue;
 
                if (!is_dmi_uuid_valid(buf, len))
                        continue;