* grub-core/net/http.c: Fix bad free.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-12 20:17:53 +02:00
parent b7d17a492f
commit 92c8f58d97
2 changed files with 16 additions and 3 deletions

View file

@ -1,3 +1,7 @@
2013-04-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/http.c: Fix bad free.
2013-04-12 Vladimir Serbinenko <phcoder@gmail.com> 2013-04-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/drivers/ieee1275/ofnet.c: Don't attempt to send more * grub-core/net/drivers/ieee1275/ofnet.c: Don't attempt to send more

View file

@ -157,9 +157,10 @@ http_err (grub_net_tcp_socket_t sock __attribute__ ((unused)),
if (data->sock) if (data->sock)
grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT); grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
data->sock = 0;
if (data->current_line) if (data->current_line)
grub_free (data->current_line); grub_free (data->current_line);
grub_free (data); data->current_line = 0;
file->device->net->eof = 1; file->device->net->eof = 1;
file->device->net->stall = 1; file->device->net->stall = 1;
if (file->size == GRUB_FILE_SIZE_UNKNOWN) if (file->size == GRUB_FILE_SIZE_UNKNOWN)
@ -175,6 +176,12 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)),
http_data_t data = file->data; http_data_t data = file->data;
grub_err_t err; grub_err_t err;
if (!data->sock)
{
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
}
while (1) while (1)
{ {
char *ptr = (char *) nb->data; char *ptr = (char *) nb->data;
@ -432,7 +439,8 @@ http_seek (struct grub_file *file, grub_off_t off)
grub_err_t err; grub_err_t err;
old_data = file->data; old_data = file->data;
/* FIXME: Reuse socket? */ /* FIXME: Reuse socket? */
grub_net_tcp_close (old_data->sock, GRUB_NET_TCP_ABORT); if (old_data->sock)
grub_net_tcp_close (old_data->sock, GRUB_NET_TCP_ABORT);
old_data->sock = 0; old_data->sock = 0;
while (file->device->net->packs.first) while (file->device->net->packs.first)
@ -529,7 +537,8 @@ http_packets_pulled (struct grub_file *file)
if (!file->device->net->eof) if (!file->device->net->eof)
file->device->net->stall = 0; file->device->net->stall = 0;
grub_net_tcp_unstall (data->sock); if (data && data->sock)
grub_net_tcp_unstall (data->sock);
return 0; return 0;
} }