protection from illformed msg

This commit is contained in:
vivek-shankar 2017-01-27 06:01:48 -05:00
parent 7c3aa655d7
commit c724900448
1 changed files with 28 additions and 25 deletions

View File

@ -87,6 +87,8 @@ namespace buzz_utility{
unMsgSize = *(uint16_t*)(pl + tot); unMsgSize = *(uint16_t*)(pl + tot);
fprintf(stdout,"received Msg size : %i\n",(int) *(uint16_t*)(pl + tot)); fprintf(stdout,"received Msg size : %i\n",(int) *(uint16_t*)(pl + tot));
/*Xbee seems to send a lots of unknown message check later, added to avoid it, safe anyways*/
if(*(uint16_t*)(pl + tot) >= 4){
tot += sizeof(uint16_t); tot += sizeof(uint16_t);
code_message_inqueue_append(pl+tot,unMsgSize); code_message_inqueue_append(pl+tot,unMsgSize);
fprintf(stdout,"Msg 1 : %i , and Msg 2: %i\n",(int) *(uint16_t*)(pl+tot),(int) *(uint8_t*)(pl+tot+sizeof(uint16_t))); fprintf(stdout,"Msg 1 : %i , and Msg 2: %i\n",(int) *(uint16_t*)(pl+tot),(int) *(uint8_t*)(pl+tot+sizeof(uint16_t)));
@ -115,6 +117,7 @@ namespace buzz_utility{
/* Process messages */ /* Process messages */
buzzvm_process_inmsgs(VM); buzzvm_process_inmsgs(VM);
} }
}
/***************************************************/ /***************************************************/
/*Obtains messages from buzz out message Queue*/ /*Obtains messages from buzz out message Queue*/
/***************************************************/ /***************************************************/