Blame SOURCES/0042-Add-forgetten-size-checks-when-using-loadfile.patch

99c779
From 972fbddde526de1249894260b7755ec6431ef609 Mon Sep 17 00:00:00 2001
99c779
From: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
99c779
Date: Mon, 9 Jan 2017 22:07:18 +0100
99c779
Subject: [PATCH 42/43] Add forgetten size checks when using loadfile.
99c779
99c779
This makes sure that lshw won't segfault when dealing
99c779
with empty files. This is similar to the following commit:
99c779
"osutils: don't segfault on empty files."
99c779
99c779
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
99c779
---
99c779
 src/core/dasd.cc | 2 +-
99c779
 src/core/pci.cc  | 2 +-
99c779
 2 files changed, 2 insertions(+), 2 deletions(-)
99c779
99c779
diff --git a/src/core/dasd.cc b/src/core/dasd.cc
99c779
index 626b8a8..b62a7ee 100644
99c779
--- a/src/core/dasd.cc
99c779
+++ b/src/core/dasd.cc
99c779
@@ -47,7 +47,7 @@ bool scan_dasd(hwNode & n)
99c779
       {
99c779
         std::string attrib_fname = std::string(SYSFS_PREFIX) + dev_name + "/device/" + *it;
99c779
         std::vector<std::string> lines;
99c779
-        if (loadfile(attrib_fname, lines))
99c779
+        if (loadfile(attrib_fname, lines) && (lines.size() > 0))
99c779
         {
99c779
           dasd_attribs[*it] = lines[0];
99c779
         }
99c779
diff --git a/src/core/pci.cc b/src/core/pci.cc
99c779
index 1d2b4ee..d1625cf 100644
99c779
--- a/src/core/pci.cc
99c779
+++ b/src/core/pci.cc
99c779
@@ -518,7 +518,7 @@ static bool load_pcidb()
99c779
   for (int i = filenames.size() - 1; i >= 0; i--)
99c779
   {
99c779
     lines.clear();
99c779
-    if (loadfile(filenames[i], lines))
99c779
+    if (loadfile(filenames[i], lines) && (lines.size() > 0))
99c779
       parse_pcidb(lines);
99c779
   }
99c779
 
99c779
-- 
99c779
2.10.2
99c779