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