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