RPL: fix a bug accessing an uninitialized pointer

This bug is uncovered when RPL_WITH_MULTICAST is enabled.
This commit is contained in:
Yasuyuki Tanaka 2017-02-07 23:59:17 +01:00
parent 3559402781
commit faeb71de00

View file

@ -748,6 +748,11 @@ dao_input_storing(void)
#if RPL_WITH_MULTICAST
if(uip_is_addr_mcast_global(&prefix)) {
/*
* "rep" is used for a unicast route which we don't need now; so set NULL so
* that operations on "rep" will be skipped.
*/
rep = NULL;
mcast_group = uip_mcast6_route_add(&prefix);
if(mcast_group) {
mcast_group->dag = dag;
@ -844,6 +849,7 @@ fwd_dao:
int should_ack = 0;
if(flags & RPL_DAO_K_FLAG) {
if(rep != NULL) {
/*
* check if this route is already installed and we can ack now!
* not pending - and same seq-no means that we can ack.
@ -856,10 +862,12 @@ fwd_dao:
should_ack = 1;
}
}
}
if(dag->preferred_parent != NULL &&
rpl_get_parent_ipaddr(dag->preferred_parent) != NULL) {
uint8_t out_seq = 0;
if(rep != NULL) {
/* if this is pending and we get the same seq no it is a retrans */
if(RPL_ROUTE_IS_DAO_PENDING(rep) &&
rep->state.dao_seqno_in == sequence) {
@ -868,6 +876,7 @@ fwd_dao:
} else {
out_seq = prepare_for_dao_fwd(sequence, rep);
}
}
PRINTF("RPL: Forwarding DAO to parent ");
PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent));