From f7e15c89f7c5ca3c7e45c097f1dae588e6969899 Mon Sep 17 00:00:00 2001 From: Burt P Date: Thu, 4 Jan 2018 20:07:29 -0600 Subject: 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 --- modules/devices/x86/processor.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'modules/devices/x86') 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); -- cgit v1.2.3