|
|
bf0270 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
bf0270 |
From: Daniel Axtens <dja@axtens.net>
|
|
|
bf0270 |
Date: Tue, 1 Mar 2022 23:14:15 +1100
|
|
|
bf0270 |
Subject: [PATCH] net/http: Do not tear down socket if it's already been torn
|
|
|
bf0270 |
down
|
|
|
bf0270 |
|
|
|
bf0270 |
It's possible for data->sock to get torn down in tcp error handling.
|
|
|
bf0270 |
If we unconditionally tear it down again we will end up doing writes
|
|
|
bf0270 |
to an offset of the NULL pointer when we go to tear it down again.
|
|
|
bf0270 |
|
|
|
bf0270 |
Detect if it has been torn down and don't do it again.
|
|
|
bf0270 |
|
|
|
bf0270 |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
bf0270 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
bf0270 |
(cherry picked from commit ec233d3ecf995293304de443579aab5c46c49e85)
|
|
|
bf0270 |
(cherry picked from commit d39cf87ed701b9f0900daed7f672e07994d37ce8)
|
|
|
bf0270 |
(cherry picked from commit e0aa5c3acec70eac3489d6df1893a93726cbce3a)
|
|
|
bf0270 |
(cherry picked from commit d29000397693cae279291b75ff89e5b9a5e2ed97)
|
|
|
bf0270 |
---
|
|
|
bf0270 |
grub-core/net/http.c | 5 +++--
|
|
|
bf0270 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
bf0270 |
|
|
|
bf0270 |
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
|
|
|
bf0270 |
index b52b558d63..5223ca57a4 100644
|
|
|
bf0270 |
--- a/grub-core/net/http.c
|
|
|
bf0270 |
+++ b/grub-core/net/http.c
|
|
|
bf0270 |
@@ -427,7 +427,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
|
|
|
bf0270 |
return err;
|
|
|
bf0270 |
}
|
|
|
bf0270 |
|
|
|
bf0270 |
- for (i = 0; !data->headers_recv && i < 100; i++)
|
|
|
bf0270 |
+ for (i = 0; data->sock && !data->headers_recv && i < 100; i++)
|
|
|
bf0270 |
{
|
|
|
bf0270 |
grub_net_tcp_retransmit ();
|
|
|
bf0270 |
grub_net_poll_cards (300, &data->headers_recv);
|
|
|
bf0270 |
@@ -435,7 +435,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
|
|
|
bf0270 |
|
|
|
bf0270 |
if (!data->headers_recv)
|
|
|
bf0270 |
{
|
|
|
bf0270 |
- grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
|
|
|
bf0270 |
+ if (data->sock)
|
|
|
bf0270 |
+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
|
|
|
bf0270 |
if (data->err)
|
|
|
bf0270 |
{
|
|
|
bf0270 |
char *str = data->errmsg;
|