Topics-2011-08-18: 0001-for-all-accesses-to-struct-route_list-rl-check-first.patch

File 0001-for-all-accesses-to-struct-route_list-rl-check-first.patch, 2.8 KB (added by Samuli Seppänen, 13 years ago)

Cron2's svn-merger patch

  • route.c

    From 237e812ef6659f26bfc0a30a8e5ab2b47ea6d270 Mon Sep 17 00:00:00 2001
    From: Gert Doering <gert@greenie.muc.de>
    Date: Tue, 16 Aug 2011 20:05:13 +0200
    Subject: [PATCH] for all accesses to "struct route_list * rl", check first that rl is
     non-NULL (in IPv4-only mode, this cannot happen, but if IPv6 is enabled
     and a servers pushes IPv6 routes and no IPv4 routes -> crash boom).
    
    Signed-off-by: Gert Doering <gert@greenie.muc.de>
    ---
     route.c |   16 ++++++++++------
     route.h |    2 +-
     2 files changed, 11 insertions(+), 7 deletions(-)
    
    diff --git a/route.c b/route.c
    index 7843686..1d8728a 100644
    a b redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u 
    808808{
    809809  const char err[] = "NOTE: unable to redirect default gateway --";
    810810
    811   if (rl->flags & RG_ENABLE)
     811  if ( rl && rl->flags & RG_ENABLE )
    812812    {
    813813      if (!(rl->spec.flags & RTSA_REMOTE_ENDPOINT))
    814814        {
    redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u 
    917917static void
    918918undo_redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
    919919{
    920   if (rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY)
     920  if ( rl && rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY )
    921921    {
    922922      /* delete remote host route */
    923923      if (rl->iflags & RL_DID_LOCAL)
    void 
    987987add_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
    988988{
    989989  redirect_default_route_to_vpn (rl, tt, flags, es);
    990   if (!(rl->iflags & RL_ROUTES_ADDED))
     990  if ( rl && !(rl->iflags & RL_ROUTES_ADDED) )
    991991    {
    992992      int i;
    993993
    void 
    10311031delete_routes (struct route_list *rl, struct route_ipv6_list *rl6,
    10321032               const struct tuntap *tt, unsigned int flags, const struct env_set *es)
    10331033{
    1034   if (rl->iflags & RL_ROUTES_ADDED)
     1034  if ( rl && rl->iflags & RL_ROUTES_ADDED )
    10351035    {
    10361036      int i;
    10371037      for (i = rl->n - 1; i >= 0; --i)
    10381038        {
    1039           const struct route *r = &rl->routes[i];
     1039          struct route * r = &rl->routes[i];
    10401040          delete_route (r, tt, flags, &rl->rgi, es);
    10411041        }
    10421042      rl->iflags &= ~RL_ROUTES_ADDED;
    10431043    }
    10441044
    10451045   undo_redirect_default_route_to_vpn (rl, tt, flags, es);
    1046    clear_route_list (rl);
     1046
     1047  if ( rl )
     1048    {
     1049      clear_route_list (rl);
     1050    }
    10471051
    10481052  if ( rl6 && rl6->routes_added )
    10491053    {
  • route.h

    diff --git a/route.h b/route.h
    index f900d3e..9953478 100644
    a b route_list_vpn_gateway_needed (const struct route_list *rl) 
    328328static inline int
    329329route_did_redirect_default_gateway(const struct route_list *rl)
    330330{
    331   return BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY);
     331  return rl && BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY);
    332332}
    333333
    334334#endif