added safeguard against absurdly large packets in rsserial.cc and output of the beginning of the packet.

This commit is contained in:
csoler 2015-12-27 10:03:07 -05:00
parent 3ea2e0f450
commit 672ab256d7

View File

@ -389,6 +389,11 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
#endif #endif
return NULL; return NULL;
} }
if(pkt_size > getRsPktMaxSize())
{
std::cerr << "(EE) trying to deserialise a packet with absurdely large size " << pkt_size << ". This means there's a bug upward or packet corruption. Packet content: " << RsUtil::BinToHex((unsigned char*)data,std::min(300u,pkt_size)) ;
return NULL ;
}
/* store the packet size to return the amount we should use up */ /* store the packet size to return the amount we should use up */
*size = pkt_size; *size = pkt_size;