]> git.proxmox.com Git - grub2.git/commitdiff
* grub-core/net/http.c: Fix bad free.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 12 Apr 2013 18:17:53 +0000 (20:17 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 12 Apr 2013 18:17:53 +0000 (20:17 +0200)
ChangeLog
grub-core/net/http.c

index ced68cc386d3ea4194a4f90efef6bce345bbcbaa..79563b8113f98a60458ed29cb90471479903e8f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * grub-core/net/drivers/ieee1275/ofnet.c: Don't attempt to send more
index a7542d1aedcd9c9ca0b3f31129a7d078ee92857a..4684f8b333c2a7bca2e1b398f2a9891380fa6696 100644 (file)
@@ -157,9 +157,10 @@ http_err (grub_net_tcp_socket_t sock __attribute__ ((unused)),
 
   if (data->sock)
     grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
+  data->sock = 0;
   if (data->current_line)
     grub_free (data->current_line);
-  grub_free (data);
+  data->current_line = 0;
   file->device->net->eof = 1;
   file->device->net->stall = 1;
   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;
   grub_err_t err;
 
+  if (!data->sock)
+    {
+      grub_netbuff_free (nb);
+      return GRUB_ERR_NONE;
+    }
+
   while (1)
     {
       char *ptr = (char *) nb->data;
@@ -432,7 +439,8 @@ http_seek (struct grub_file *file, grub_off_t off)
   grub_err_t err;
   old_data = file->data;
   /* 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;
 
   while (file->device->net->packs.first)
@@ -529,7 +537,8 @@ http_packets_pulled (struct grub_file *file)
 
   if (!file->device->net->eof)
     file->device->net->stall = 0;
-  grub_net_tcp_unstall (data->sock);
+  if (data && data->sock)
+    grub_net_tcp_unstall (data->sock);
   return 0;
 }