1 Star 0 Fork 50

Meredith/grub2

forked from src-anolis-os/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0480-efi-net-Fix-malformed-device-path-arithmetic-errors-.patch 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2022-04-13 15:15 . update to grub2-2.02-120.el8.src.rpm
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thomas Frauendorfer | Miray Software <tf@miray.de>
Date: Tue, 4 Aug 2020 17:13:05 +0200
Subject: [PATCH] efi/net: Fix malformed device path arithmetic errors in efi
net methods
---
grub-core/net/efi/net.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
index 3ae1fbbe3..a58c24f63 100644
--- a/grub-core/net/efi/net.c
+++ b/grub-core/net/efi/net.c
@@ -1318,11 +1318,18 @@ grub_efi_net_boot_from_https (void)
dp = grub_efi_get_device_path (image->device_handle);
- while (1)
+ while (dp)
{
+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+ if (len < 4)
+ {
+ grub_error(GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%d", len);
+ break;
+ }
+
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
- grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
if ((type == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE)
&& (subtype == GRUB_EFI_URI_DEVICE_PATH_SUBTYPE))
@@ -1335,7 +1342,7 @@ grub_efi_net_boot_from_https (void)
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
break;
- dp = (grub_efi_device_path_t *) ((char *) dp + len);
+ dp = GRUB_EFI_NEXT_DEVICE_PATH(dp);
}
return 0;
@@ -1353,11 +1360,18 @@ grub_efi_net_boot_from_opa (void)
dp = grub_efi_get_device_path (image->device_handle);
- while (1)
+ while (dp)
{
+ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
+ if (len < 4)
+ {
+ grub_error(GRUB_ERR_OUT_OF_RANGE,
+ "malformed EFI Device Path node has length=%d", len);
+ break;
+ }
+
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp);
- grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp);
if ((type == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE)
&& (subtype == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE))
@@ -1368,7 +1382,7 @@ grub_efi_net_boot_from_opa (void)
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
break;
- dp = (grub_efi_device_path_t *) ((char *) dp + len);
+ dp = GRUB_EFI_NEXT_DEVICE_PATH(dp);
}
return 0;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yueeranna/grub2.git
git@gitee.com:yueeranna/grub2.git
yueeranna
grub2
grub2
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385