From dc686ad10b86d3681d2f6ab6d9835e53222848eb Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Fri, 7 Sep 2012 11:34:00 +0930 Subject: [PATCH] Set incoming packet length --- overlay_mdp.c | 4 ++-- overlay_olsr.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/overlay_mdp.c b/overlay_mdp.c index d25ed4bf..8bbf727a 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -413,6 +413,8 @@ int overlay_saw_mdp_containing_frame(struct overlay_frame *f, time_ms_t now) overlay_mdp_frame mdp; int len=f->payload->sizeLimit; + if (len<10) RETURN(WHY("Invalid MDP frame")); + /* Get source and destination addresses */ if (f->destination) bcopy(f->destination->sid,mdp.in.dst.sid,SID_SIZE); @@ -423,8 +425,6 @@ int overlay_saw_mdp_containing_frame(struct overlay_frame *f, time_ms_t now) } bcopy(f->source->sid,mdp.in.src.sid,SID_SIZE); - if (len<10) RETURN(WHY("Invalid MDP frame")); - /* copy crypto flags from frame so that we know if we need to decrypt or verify it */ if (overlay_mdp_decrypt(f,&mdp)) RETURN(-1); diff --git a/overlay_olsr.c b/overlay_olsr.c index fc440ea2..5413e3b4 100644 --- a/overlay_olsr.c +++ b/overlay_olsr.c @@ -173,6 +173,7 @@ static void olsr_read(struct sched_ent *alarm){ } struct overlay_buffer *b = ob_static(buff, msg_len); + ob_limitsize(b, msg_len); parse_frame(b); ob_free(b);