Skip to content
Snippets Groups Projects
Commit 6df71871 authored by Daniel Axtens's avatar Daniel Axtens Committed by Julian Andres Klode
Browse files

net/http: Do not tear down socket if it's already been torn down


It's possible for data->sock to get torn down in tcp error handling.
If we unconditionally tear it down again we will end up doing writes
to an offset of the NULL pointer when we go to tear it down again.

Detect if it has been torn down and don't do it again.

Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
parent fb66f40b
No related branches found
No related tags found
No related merge requests found
......@@ -422,7 +422,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
return err;
}
for (i = 0; !data->headers_recv && i < 100; i++)
for (i = 0; data->sock && !data->headers_recv && i < 100; i++)
{
grub_net_tcp_retransmit ();
grub_net_poll_cards (300, &data->headers_recv);
......@@ -430,7 +430,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
if (!data->headers_recv)
{
grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
if (data->sock)
grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
if (data->err)
{
char *str = data->errmsg;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment