aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2018-01-04 20:07:29 -0600
committerLeandro A. F. Pereira <leandro@hardinfo.org>2018-02-09 08:24:50 -0800
commitf7e15c89f7c5ca3c7e45c097f1dae588e6969899 (patch)
treed47a6eecf937759bd83cbca8f270357d8daceb1b
parentec35a12e12118ba46ceb26e1574139045d16f594 (diff)
x86: increase the cpuinfo read buffer size
The flags list is often more than 512 bytes long these days. It was being truncated. Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--modules/devices/x86/processor.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/devices/x86/processor.c b/modules/devices/x86/processor.c
index 5b62e51b..f18ef155 100644
--- a/modules/devices/x86/processor.c
+++ b/modules/devices/x86/processor.c
@@ -341,19 +341,23 @@ gchar *caches_summary(GSList * processors)
return ret;
}
-
+#define PROC_SCAN_READ_BUFFER_SIZE 896
GSList *processor_scan(void)
{
GSList *procs = NULL, *l = NULL;
Processor *processor = NULL;
FILE *cpuinfo;
- gchar buffer[512];
+ gchar buffer[PROC_SCAN_READ_BUFFER_SIZE];
cpuinfo = fopen(PROC_CPUINFO, "r");
if (!cpuinfo)
return NULL;
- while (fgets(buffer, 512, cpuinfo)) {
+ while (fgets(buffer, PROC_SCAN_READ_BUFFER_SIZE, cpuinfo)) {
+ int rlen = strlen(buffer);
+ if (rlen >= PROC_SCAN_READ_BUFFER_SIZE - 1) {
+ fprintf(stderr, "Warning: truncated a line (probably flags list) longer than %d bytes while reading %s.\n", PROC_SCAN_READ_BUFFER_SIZE, PROC_CPUINFO);
+ }
gchar **tmp = g_strsplit(buffer, ":", 2);
if (!tmp[1] || !tmp[0]) {
g_strfreev(tmp);