lshw/lshw-fix-mmc.patch

54 lines
1.4 KiB
Diff
Raw Normal View History

From 2524bb3def3009e53a78e600bbea2c4639dc1e99 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 24 Apr 2020 15:02:44 +0200
Subject: [PATCH] Fix type used for read to ssize_t.
Function declaration:
ssize_t read(int fd, void *buf, size_t count);
With size_t the following expression is always true:
while ((count = read(cpuinfo, buffer, sizeof(buffer))) > 0)
and bad things happen.
---
src/core/cpuinfo.cc | 2 +-
src/core/osutils.cc | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
index eceb83a..3dbdd0c 100644
--- a/src/core/cpuinfo.cc
+++ b/src/core/cpuinfo.cc
@@ -589,7 +589,7 @@ bool scan_cpuinfo(hwNode & n)
if (core)
{
char buffer[1024];
- size_t count;
+ ssize_t count;
string cpuinfo_str = "";
string description = "", version = "";
string plat = platform();
diff --git a/src/core/osutils.cc b/src/core/osutils.cc
index f023a46..a53ed89 100644
--- a/src/core/osutils.cc
+++ b/src/core/osutils.cc
@@ -148,7 +148,7 @@ vector < string > &list)
{
char buffer[1024];
string buffer_str = "";
- size_t count = 0;
+ ssize_t count = 0;
data_file fd = file_open(file);
if (file_open_error(fd))
@@ -174,7 +174,7 @@ const string & def)
if (fd >= 0)
{
char buffer[1024];
- size_t count = 0;
+ ssize_t count = 0;
memset(buffer, 0, sizeof(buffer));
result = "";