From e1cc7078cc48c9ca081c0c5f4acc8d15212a1a06 Mon Sep 17 00:00:00 2001 From: scipio Date: Thu, 19 Apr 2007 22:45:47 +0000 Subject: [PATCH] Bug fix from John Regehr. --- tos/lib/serial/SerialDispatcherP.nc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tos/lib/serial/SerialDispatcherP.nc b/tos/lib/serial/SerialDispatcherP.nc index cc85a3f3..fdcb5b6f 100644 --- a/tos/lib/serial/SerialDispatcherP.nc +++ b/tos/lib/serial/SerialDispatcherP.nc @@ -102,13 +102,21 @@ implementation { return EBUSY; } - sendState = SEND_STATE_DATA; - sendId = id; - sendCancelled = FALSE; atomic { + sendIndex = call PacketInfo.offset[id](); + if (sendIndex > sizeof(message_header_t)) { + return ESIZE; + } + sendError = SUCCESS; sendBuffer = (uint8_t*)msg; - sendIndex = call PacketInfo.offset[id](); + sendState = SEND_STATE_DATA; + sendId = id; + sendCancelled = FALSE; + // If something we're starting past the header, something is wrong + // Bug fix from John Regehr + + // sendLen is where in the buffer the packet stops. // This is the length of the packet, plus its start point sendLen = call PacketInfo.dataLinkLength[id](msg, len) + sendIndex; -- 2.39.2