1 Star 0 Fork 83

ridedolphin / grub2

forked from src-openEuler / grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0137-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
zhangqiumiao 提交于 2022-03-07 17:05 . update to version 2.06
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 2 Jun 2020 13:25:01 +0200
Subject: [PATCH] http: Prepend prefix when the HTTP path is relative as done
in efi/http
There are two different HTTP drivers that can be used when requesting an
HTTP resource: the efi/http that uses the EFI_HTTP_PROTOCOL and the http
that uses GRUB's HTTP and TCP/IP implementation.
The efi/http driver appends a prefix that is defined in the variable
http_path, but the http driver doesn't.
So using this driver and attempting to fetch a resource using a relative
path fails.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/net/http.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index b52b558d631..7f878b56157 100644
--- a/grub-core/net/http.c
+++ b/grub-core/net/http.c
@@ -501,13 +501,20 @@ http_open (struct grub_file *file, const char *filename)
{
grub_err_t err;
struct http_data *data;
+ const char *http_path;
data = grub_zalloc (sizeof (*data));
if (!data)
return grub_errno;
file->size = GRUB_FILE_SIZE_UNKNOWN;
- data->filename = grub_strdup (filename);
+ /* If path is relative, prepend http_path */
+ http_path = grub_env_get ("http_path");
+ if (http_path && filename[0] != '/')
+ data->filename = grub_xasprintf ("%s/%s", http_path, filename);
+ else
+ data->filename = grub_strdup (filename);
+
if (!data->filename)
{
grub_free (data);
1
https://gitee.com/ridedolphin/grub2.git
git@gitee.com:ridedolphin/grub2.git
ridedolphin
grub2
grub2
master

搜索帮助