SHA256
1
0
forked from pool/systemd
systemd/0005-bootchart-Do-not-try-to-access-data-for-non-existing.patch

30 lines
1.0 KiB
Diff
Raw Normal View History

From c119700c06b248b1c2a082b40b1a346f58d89da0 Mon Sep 17 00:00:00 2001
From: Philippe De Swert <philippe.deswert@jollamobile.com>
Date: Sun, 28 Sep 2014 18:12:51 +0300
Subject: [PATCH] bootchart: Do not try to access data for non-existing CPU's
Cpu's are assigned normally, so starting at 0, so the MAX_CPU index will
always be one smaller than the actual number.
Found with Coverity.
---
src/bootchart/store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git src/bootchart/store.c src/bootchart/store.c
index 3099ff1..9ea1b27 100644
--- src/bootchart/store.c
+++ src/bootchart/store.c
@@ -199,7 +199,7 @@ vmstat_next:
if (strstr(key, "cpu")) {
r = safe_atoi((const char*)(key+3), &c);
- if (r < 0 || c > MAXCPUS)
+ if (r < 0 || c > MAXCPUS -1)
/* Oops, we only have room for MAXCPUS data */
break;
sampledata->runtime[c] = atoll(rt);
--
1.7.9.2