From: scipio Date: Thu, 19 Apr 2007 22:45:47 +0000 (+0000) Subject: Bug fix from John Regehr. X-Git-Tag: tinyos/2.0.1~25 X-Git-Url: https://oss.titaniummirror.com/gitweb?a=commitdiff_plain;h=e1cc7078cc48c9ca081c0c5f4acc8d15212a1a06;p=tinyos-2.x.git Bug fix from John Regehr. --- 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;