From f94d6df6f0aaed13fce3ffa404deea51a2c1edd4 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Wed, 27 Jan 2010 08:12:56 +0000 Subject: [PATCH] Bugfix: copy the originator address from the packetbuf into a local variable to avoid it being overwritten --- core/net/rime/route-discovery.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/net/rime/route-discovery.c b/core/net/rime/route-discovery.c index 89ec5d2a0..8f3fe8b51 100644 --- a/core/net/rime/route-discovery.c +++ b/core/net/rime/route-discovery.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: route-discovery.c,v 1.19 2009/11/08 19:40:17 adamdunkels Exp $ + * $Id: route-discovery.c,v 1.20 2010/01/27 08:12:56 adamdunkels Exp $ */ /** @@ -188,7 +188,13 @@ rrep_packet_received(struct unicast_conn *uc, const rimeaddr_t *from) rrep_pending = 0; ctimer_stop(&c->t); if(c->cb->new_route) { - c->cb->new_route(c, &msg->originator); + rimeaddr_t originator; + + /* If the callback modifies the packet, the originator address + will be lost. Therefore, we need to copy it into a local + variable before calling the callback. */ + rimeaddr_copy(&originator, &msg->originator); + c->cb->new_route(c, &originator); } } else {