fixed bug in serializer caused to not updating the size parameter. Also fixes unittests

This commit is contained in:
csoler 2017-05-06 13:23:26 +02:00
parent f7f0d8ddd0
commit 868c0467f2
2 changed files with 9 additions and 3 deletions

View File

@ -387,7 +387,7 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
//std::cerr << "RsSerialiser::deserialise() RsItem Type: " << std::hex << getRsItemId(data) << " Size: " << pkt_size;
//std::cerr << std::endl;
if (pkt_size != *size)
if (pkt_size > *size)
{
#ifdef RSSERIAL_ERROR_DEBUG
std::cerr << "RsSerialiser::deserialise() ERROR Size mismatch(2)";

View File

@ -60,12 +60,14 @@ RsItem *RsServiceSerializer::deserialise(void *data, uint32_t *size)
item->serial_process(RsGenericSerializer::DESERIALIZE, ctx) ;
if(ctx.mSize != ctx.mOffset)
if(ctx.mSize < ctx.mOffset)
{
std::cerr << "RsSerializer::deserialise(): ERROR. offset does not match expected size!" << std::endl;
delete item ;
return NULL ;
}
*size = ctx.mOffset ;
if(ctx.mOk)
return item ;
@ -96,12 +98,14 @@ RsItem *RsConfigSerializer::deserialise(void *data, uint32_t *size)
item->serial_process(DESERIALIZE, ctx) ;
if(ctx.mSize != ctx.mOffset)
if(ctx.mSize < ctx.mOffset)
{
std::cerr << "RsSerializer::deserialise(): ERROR. offset does not match expected size!" << std::endl;
delete item ;
return NULL ;
}
*size = ctx.mOffset ;
if(ctx.mOk)
return item ;
@ -139,6 +143,8 @@ bool RsGenericSerializer::serialise(RsItem *item,void *data,uint32_t *size)
std::cerr << "RsSerializer::serialise(): ERROR. offset does not match expected size!" << std::endl;
return false ;
}
*size = ctx.mOffset ;
return true ;
}