mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
fixed bug in serializer caused to not updating the size parameter. Also fixes unittests
This commit is contained in:
parent
f7f0d8ddd0
commit
868c0467f2
@ -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)";
|
||||
|
@ -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 ;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user