Blame SOURCES/0019-Don-t-go-past-the-last-element-of-indexVars-in-findE.patch

903092
From 5851c34b92069dd955e862b856bb732eb263b058 Mon Sep 17 00:00:00 2001
903092
From: Yannick Brosseau <scientist@fb.com>
903092
Date: Thu, 3 Jul 2014 13:55:19 -0700
903092
Subject: [PATCH 19/41] Don't go past the last element of indexVars in
903092
 findEntryByPath
903092
903092
We add a chance of creating an infinite loop, because we
903092
were reading memory past the last element of indexVars set to -1.
903092
903092
This issue was only apparent with -O2, probably because the way the
903092
memory was initialized.
903092
903092
Signed-off-by: Yannick Brosseau <scientist@fb.com>
903092
---
903092
 grubby.c | 8 +++++---
903092
 1 file changed, 5 insertions(+), 3 deletions(-)
903092
903092
diff --git a/grubby.c b/grubby.c
903092
index 4516b92..4462fb9 100644
903092
--- a/grubby.c
903092
+++ b/grubby.c
903092
@@ -1954,11 +1954,13 @@ struct singleEntry * findEntryByPath(struct grubConfig * config,
903092
 	}
903092
 
903092
 	indexVars[i + 1] = -1;
903092
-	
903092
+
903092
 	i = 0;
903092
 	if (index) {
903092
-	    while (i < *index) i++;
903092
-	    if (indexVars[i] == -1) return NULL;
903092
+	    while (i < *index) {
903092
+		i++;
903092
+		if (indexVars[i] == -1) return NULL;
903092
+	    }
903092
 	}
903092
 
903092
 	entry = findEntryByIndex(config, indexVars[i]);
903092
-- 
903092
2.4.3
903092