All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/route: Fix NULL pointer dereference when deleting last route
@ 2011-12-06  9:42 Jeremy Kerr
  2011-12-23 10:54 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Kerr @ 2011-12-06  9:42 UTC (permalink / raw)
  To: grub-devel

Currently, grub_cmd_delroute will crash when deleting the last route.
In the deletion code, we remove the matching route from the route list:
      
  *prev = route->next
      
- route->next being NULL to mark the end of the list. We then process
the for loop's iterator, which contains:

  prev = &((*prev)->next)

ie,

  prev = NULL->next;

Instead, break out of the for-loop when we've deleted the route.

	* grub-core/net/net.c (grub_cmd_delroute): fix NULL deref when deleting
	last route

---
 grub-core/net/net.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 09acea9..cafec41 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -430,6 +430,7 @@ grub_cmd_delroute (struct grub_command *cmd __attribute__ ((unused)),
 	*prev = route->next;
 	grub_free (route->name);
 	grub_free (route);
+	break;
       }
 
   return GRUB_ERR_NONE;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/route: Fix NULL pointer dereference when deleting last route
  2011-12-06  9:42 [PATCH] net/route: Fix NULL pointer dereference when deleting last route Jeremy Kerr
@ 2011-12-23 10:54 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2011-12-23 10:54 UTC (permalink / raw)
  To: grub-devel

On 06.12.2011 10:42, Jeremy Kerr wrote:
> Currently, grub_cmd_delroute will crash when deleting the last route.
> In the deletion code, we remove the matching route from the route list:
>
>    *prev = route->next
>
> - route->next being NULL to mark the end of the list. We then process
> the for loop's iterator, which contains:
>
>    prev =&((*prev)->next)
>
> ie,
>
>    prev = NULL->next;
>
> Instead, break out of the for-loop when we've deleted the route.
>
> 	* grub-core/net/net.c (grub_cmd_delroute): fix NULL deref when deleting
> 	last route
Bug is real but fix is wrong. Committed the right fix.
> ---
>   grub-core/net/net.c |    1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/grub-core/net/net.c b/grub-core/net/net.c
> index 09acea9..cafec41 100644
> --- a/grub-core/net/net.c
> +++ b/grub-core/net/net.c
> @@ -430,6 +430,7 @@ grub_cmd_delroute (struct grub_command *cmd __attribute__ ((unused)),
>   	*prev = route->next;
>   	grub_free (route->name);
>   	grub_free (route);
> +	break;
>         }
>
>     return GRUB_ERR_NONE;
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-23 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06  9:42 [PATCH] net/route: Fix NULL pointer dereference when deleting last route Jeremy Kerr
2011-12-23 10:54 ` Vladimir 'φ-coder/phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.