50 lines
1.4 KiB
Diff
50 lines
1.4 KiB
Diff
|
|
From 8ab70a85bbda79d47c8cc8e1c2767e1cb307f536 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Neil Horman <nhorman@tuxdriver.com>
|
||
|
|
Date: Tue, 29 May 2018 11:07:32 -0400
|
||
|
|
Subject: [PATCH 085/112] parse_proc_interrupts: ensure that buffer is long
|
||
|
|
enough for a string
|
||
|
|
|
||
|
|
Instead of using strcpy to a save each line in /proc/interrupts, use
|
||
|
|
strdup and free to ensure that the buffer will hold the string
|
||
|
|
consistently, avoiding the gcc error that using a fixed size stack
|
||
|
|
variable triggers
|
||
|
|
|
||
|
|
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
|
||
|
|
---
|
||
|
|
procinterrupts.c | 5 +++--
|
||
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/procinterrupts.c b/procinterrupts.c
|
||
|
|
index 1aa4413..4ef8751 100644
|
||
|
|
--- a/procinterrupts.c
|
||
|
|
+++ b/procinterrupts.c
|
||
|
|
@@ -170,7 +170,7 @@ GList* collect_full_irq_list()
|
||
|
|
int number;
|
||
|
|
struct irq_info *info;
|
||
|
|
char *c;
|
||
|
|
- char savedline[1024];
|
||
|
|
+ char *savedline = NULL;
|
||
|
|
|
||
|
|
if (getline(&line, &size, file)==0)
|
||
|
|
break;
|
||
|
|
@@ -186,7 +186,7 @@ GList* collect_full_irq_list()
|
||
|
|
if (!c)
|
||
|
|
continue;
|
||
|
|
|
||
|
|
- strncpy(savedline, line, sizeof(savedline));
|
||
|
|
+ savedline = strdup(line);
|
||
|
|
irq_name = strtok_r(savedline, " ", &savedptr);
|
||
|
|
last_token = strtok_r(NULL, " ", &savedptr);
|
||
|
|
while ((p = strtok_r(NULL, " ", &savedptr))) {
|
||
|
|
@@ -224,6 +224,7 @@ GList* collect_full_irq_list()
|
||
|
|
info->name = strdupa(irq_mod);
|
||
|
|
tmp_list = g_list_append(tmp_list, info);
|
||
|
|
}
|
||
|
|
+ free(savedline);
|
||
|
|
}
|
||
|
|
fclose(file);
|
||
|
|
free(line);
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|