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>
Acked-By: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
... | ... |
@@ -808,7 +808,7 @@ redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u |
808 | 808 |
{ |
809 | 809 |
const char err[] = "NOTE: unable to redirect default gateway --"; |
810 | 810 |
|
811 |
- if (rl->flags & RG_ENABLE) |
|
811 |
+ if ( rl && rl->flags & RG_ENABLE ) |
|
812 | 812 |
{ |
813 | 813 |
if (!(rl->spec.flags & RTSA_REMOTE_ENDPOINT)) |
814 | 814 |
{ |
... | ... |
@@ -917,7 +917,7 @@ redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, u |
917 | 917 |
static void |
918 | 918 |
undo_redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, unsigned int flags, const struct env_set *es) |
919 | 919 |
{ |
920 |
- if (rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY) |
|
920 |
+ if ( rl && rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY ) |
|
921 | 921 |
{ |
922 | 922 |
/* delete remote host route */ |
923 | 923 |
if (rl->iflags & RL_DID_LOCAL) |
... | ... |
@@ -987,7 +987,7 @@ void |
987 | 987 |
add_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es) |
988 | 988 |
{ |
989 | 989 |
redirect_default_route_to_vpn (rl, tt, flags, es); |
990 |
- if (!(rl->iflags & RL_ROUTES_ADDED)) |
|
990 |
+ if ( rl && !(rl->iflags & RL_ROUTES_ADDED) ) |
|
991 | 991 |
{ |
992 | 992 |
int i; |
993 | 993 |
|
... | ... |
@@ -1031,19 +1031,23 @@ void |
1031 | 1031 |
delete_routes (struct route_list *rl, struct route_ipv6_list *rl6, |
1032 | 1032 |
const struct tuntap *tt, unsigned int flags, const struct env_set *es) |
1033 | 1033 |
{ |
1034 |
- if (rl->iflags & RL_ROUTES_ADDED) |
|
1034 |
+ if ( rl && rl->iflags & RL_ROUTES_ADDED ) |
|
1035 | 1035 |
{ |
1036 | 1036 |
int i; |
1037 | 1037 |
for (i = rl->n - 1; i >= 0; --i) |
1038 | 1038 |
{ |
1039 |
- const struct route *r = &rl->routes[i]; |
|
1039 |
+ struct route * r = &rl->routes[i]; |
|
1040 | 1040 |
delete_route (r, tt, flags, &rl->rgi, es); |
1041 | 1041 |
} |
1042 | 1042 |
rl->iflags &= ~RL_ROUTES_ADDED; |
1043 | 1043 |
} |
1044 | 1044 |
|
1045 | 1045 |
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 |
+ } |
|
1047 | 1051 |
|
1048 | 1052 |
if ( rl6 && rl6->routes_added ) |
1049 | 1053 |
{ |
... | ... |
@@ -328,7 +328,7 @@ route_list_vpn_gateway_needed (const struct route_list *rl) |
328 | 328 |
static inline int |
329 | 329 |
route_did_redirect_default_gateway(const struct route_list *rl) |
330 | 330 |
{ |
331 |
- return BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY); |
|
331 |
+ return rl && BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY); |
|
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
#endif |