代码拉取完成,页面将自动刷新
From 87aca3738c9c8168e43349910eed08ebbc779a77 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Thu, 5 Mar 2020 16:21:58 +0100
Subject: [PATCH 242/272] efi/http: Enclose literal IPv6 addresses in square
brackets
According to RFC 2732 (https://www.ietf.org/rfc/rfc2732.txt), literal IPv6
addresses must be enclosed in square brackets. But GRUB currently does not
do this and is causing HTTP servers to send Bad Request (400) responses.
For example, the following is the HTTP stream when fetching a config file:
HEAD /EFI/BOOT/grub.cfg HTTP/1.1
Host: 2000:dead:beef:a::1
Accept: */*
User-Agent: UefiHttpBoot/1.0
HTTP/1.1 400 Bad Request
Date: Thu, 05 Mar 2020 14:46:02 GMT
Server: Apache/2.4.41 (Fedora) OpenSSL/1.1.1d
Connection: close
Content-Type: text/html; charset=iso-8859-1
and after enclosing the IPv6 address the HTTP request is successful:
HEAD /EFI/BOOT/grub.cfg HTTP/1.1
Host: [2000:dead:beef:a::1]
Accept: */*
User-Agent: UefiHttpBoot/1.0
HTTP/1.1 200 OK
Date: Thu, 05 Mar 2020 14:48:04 GMT
Server: Apache/2.4.41 (Fedora) OpenSSL/1.1.1d
Last-Modified: Thu, 27 Feb 2020 17:45:58 GMT
ETag: "206-59f924b24b1da"
Accept-Ranges: bytes
Content-Length: 518
Resolves: rhbz#1732765
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/net/efi/http.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
index b20e99100..5b4ebfb99 100644
--- a/grub-core/net/efi/http.c
+++ b/grub-core/net/efi/http.c
@@ -159,13 +159,7 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https,
grub_efi_status_t status;
grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
char *url = NULL;
-
- request_headers[0].field_name = (grub_efi_char8_t *)"Host";
- request_headers[0].field_value = (grub_efi_char8_t *)server;
- request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
- request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
- request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
- request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
+ char *hostname = NULL;
{
grub_efi_ipv6_address_t address;
@@ -176,10 +170,24 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https,
grub_size_t sz;
if (grub_efi_string_to_ip6_address (server, &address, &rest) && *rest == 0)
- url = grub_xasprintf ("%s://[%s]%s", protocol, server, name);
+ {
+ hostname = grub_xasprintf ("[%s]", server);
+ if (!hostname)
+ return GRUB_ERR_OUT_OF_MEMORY;
+
+ server = hostname;
+
+ url = grub_xasprintf ("%s://%s%s", protocol, server, name);
+ if (!url)
+ {
+ grub_free (hostname);
+ return GRUB_ERR_OUT_OF_MEMORY;
+ }
+ }
else
+ {
url = grub_xasprintf ("%s://%s%s", protocol, server, name);
-
+ }
if (!url)
{
return grub_errno;
@@ -204,6 +212,13 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https,
request_data.url = ucs2_url;
}
+ request_headers[0].field_name = (grub_efi_char8_t *)"Host";
+ request_headers[0].field_value = (grub_efi_char8_t *)server;
+ request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
+ request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
+ request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
+ request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
+
request_data.method = (headeronly > 0) ? GRUB_EFI_HTTPMETHODHEAD : GRUB_EFI_HTTPMETHODGET;
request_message.data.request = &request_data;
@@ -233,6 +248,9 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https,
status = http->request (http, &request_token);
+ if (hostname)
+ grub_free (hostname);
+
if (status != GRUB_EFI_SUCCESS)
{
b->close_event (request_token.event);
--
2.41.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。