]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Bug fix from John Regehr.
authorscipio <scipio>
Thu, 19 Apr 2007 22:45:47 +0000 (22:45 +0000)
committerscipio <scipio>
Thu, 19 Apr 2007 22:45:47 +0000 (22:45 +0000)
tos/lib/serial/SerialDispatcherP.nc

index cc85a3f3f530c511019ace6bc721ada7e588077b..fdcb5b6fe0548bcdc809b5039d253a6846dd3432 100644 (file)
@@ -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;