Repository : ssh://git@open-mesh.org/batmand
On branch : master
commit 036aea1fe69d275aecae64cc643e8e34fac550a0 Author: Sven Eckelmann sven@narfation.org Date: Tue Jun 17 21:56:04 2014 +0200
batmand: Don't dereference orig_node before checking for NULL
The update_route functions first stores the orig_node->router in an extra variable and later checks if orig_node is NULL. This is not only a potential cause of a crash but can also cause new compilers to drop the NULL check completely [1].
[1] https://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Optimize-Options.html#index-fde...
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Elektra Wagenrad onelektra@gmx.net
036aea1fe69d275aecae64cc643e8e34fac550a0 batman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/batman.c b/batman.c index 89b3bf1..c3dfa7f 100644 --- a/batman.c +++ b/batman.c @@ -353,10 +353,9 @@ void update_routes(struct orig_node *orig_node, struct neigh_node *neigh_node, u prof_start(PROF_update_routes); debug_output(4, "update_routes() \n");
- old_router = orig_node->router; - /* also handles orig_node->router == NULL and neigh_node == NULL */ if ((orig_node != NULL) && (orig_node->router != neigh_node)) { + old_router = orig_node->router;
if ( ( orig_node != NULL ) && ( neigh_node != NULL ) ) { addr_to_string( orig_node->orig, orig_str, ADDR_STR_LEN ); @@ -415,7 +414,8 @@ void update_routes(struct orig_node *orig_node, struct neigh_node *neigh_node, u orig_node->router = neigh_node;
} else if (orig_node != NULL) { - hna_global_update(orig_node, hna_recv_buff, hna_buff_len, old_router); + hna_global_update(orig_node, hna_recv_buff, hna_buff_len, + orig_node->router); }
prof_stop(PROF_update_routes);