8 Star 0 Fork 11

src-anolis-os/grubby

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0037-Fix-findTemplate-index-logic-1285601.patch 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:34 . import grubby-8.40-38.el8.src.rpm
From 46843e71656264d98ceda79985e5d341a8d58aa7 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 22 Dec 2016 17:52:14 -0500
Subject: [PATCH 37/55] Fix findTemplate index logic (#1285601)
The fallback case where findTemplate has to look for the first entry
contained a logic flaw that could return an incorrect index. This
discovered index should be reduced by one for each boot entry that will
be skipped in the final output. The flaw occurred because the index
variable was used for the loop upper bound at the same time as it was
being decremented within the actual loop body. The loop would thus fail
to examine a number of boot entries equal to the total number of
iterations the loop performed.
Related: rhbz#1285601
---
grubby.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/grubby.c b/grubby.c
index fcca6364887..692c351ccb6 100644
--- a/grubby.c
+++ b/grubby.c
@@ -2436,8 +2436,11 @@ struct singleEntry *findTemplate(struct grubConfig *cfg, const char *prefix,
index = 0;
while ((entry = findEntryByIndex(cfg, index))) {
if (suitableImage(entry, prefix, skipRemoved, flags)) {
- int j;
- for (j = 0; j < index; j++) {
+ int j, unmodifiedIndex;
+
+ unmodifiedIndex = index;
+
+ for (j = 0; j < unmodifiedIndex; j++) {
entry2 = findEntryByIndex(cfg, j);
if (entry2->skip)
index--;
--
2.17.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/grubby.git
git@gitee.com:src-anolis-os/grubby.git
src-anolis-os
grubby
grubby
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385