|
|
903092 |
From 3d6e04814d4578a4f57cfc98709ec0640428977e Mon Sep 17 00:00:00 2001
|
|
|
903092 |
From: Robert Marshall <rmarshall@redhat.com>
|
|
|
903092 |
Date: Thu, 22 Dec 2016 17:52:14 -0500
|
|
|
903092 |
Subject: [PATCH 68/69] Fix findTemplate index logic (#1285601)
|
|
|
903092 |
|
|
|
903092 |
The fallback case where findTemplate has to look for the first entry
|
|
|
903092 |
contained a logic flaw that could return an incorrect index. This
|
|
|
903092 |
discovered index should be reduced by one for each boot entry that will
|
|
|
903092 |
be skipped in the final output. The flaw occurred because the index
|
|
|
903092 |
variable was used for the loop upper bound at the same time as it was
|
|
|
903092 |
being decremented within the actual loop body. The loop would thus fail
|
|
|
903092 |
to examine a number of boot entries equal to the total number of
|
|
|
903092 |
iterations the loop performed.
|
|
|
903092 |
|
|
|
903092 |
Related: rhbz#1285601
|
|
|
903092 |
---
|
|
|
903092 |
grubby.c | 7 +++++--
|
|
|
903092 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
903092 |
|
|
|
903092 |
diff --git a/grubby.c b/grubby.c
|
|
|
903092 |
index 4e872c0..57c1ed7 100644
|
|
|
903092 |
--- a/grubby.c
|
|
|
903092 |
+++ b/grubby.c
|
|
|
903092 |
@@ -2534,8 +2534,11 @@ struct singleEntry *findTemplate(struct grubConfig *cfg, const char *prefix,
|
|
|
903092 |
index = 0;
|
|
|
903092 |
while ((entry = findEntryByIndex(cfg, index))) {
|
|
|
903092 |
if (suitableImage(entry, prefix, skipRemoved, flags)) {
|
|
|
903092 |
- int j;
|
|
|
903092 |
- for (j = 0; j < index; j++) {
|
|
|
903092 |
+ int j, unmodifiedIndex;
|
|
|
903092 |
+
|
|
|
903092 |
+ unmodifiedIndex = index;
|
|
|
903092 |
+
|
|
|
903092 |
+ for (j = 0; j < unmodifiedIndex; j++) {
|
|
|
903092 |
entry2 = findEntryByIndex(cfg, j);
|
|
|
903092 |
if (entry2->skip)
|
|
|
903092 |
index--;
|
|
|
903092 |
--
|
|
|
903092 |
2.9.3
|
|
|
903092 |
|