mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-27 23:57:38 -04:00
Merge branch 'master' into gxs_mail_experiments
This commit is contained in:
commit
c0c5cc52db
94 changed files with 3054 additions and 783 deletions
|
@ -37,6 +37,8 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
/***
|
||||
* #define RSSERIAL_DEBUG 1
|
||||
|
@ -385,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 ;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "util/rsprint.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <typeinfo>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
static const uint32_t MAX_SERIALIZED_ARRAY_SIZE = 500 ;
|
||||
static const uint32_t MAX_SERIALIZED_CHUNK_SIZE = 10*1024*1024 ; // 10 MB.
|
||||
|
@ -192,7 +195,7 @@ template<> void RsTypeSerializer::print_data(const std::string& n, uint16_t type
|
|||
// TlvInt with subtype //
|
||||
//=================================================================================================//
|
||||
|
||||
template<> uint32_t RsTypeSerializer::serial_size(uint16_t /* type_subtype */,const uint32_t& s)
|
||||
template<> uint32_t RsTypeSerializer::serial_size(uint16_t /* type_subtype */,const uint32_t& /*s*/)
|
||||
{
|
||||
return GetTlvUInt32Size() ;
|
||||
}
|
||||
|
|
|
@ -452,7 +452,6 @@ protected:
|
|||
template<typename T> static void print_data(
|
||||
const std::string& name,uint16_t type_id,const T& member );
|
||||
|
||||
|
||||
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER>
|
||||
static bool serialize(
|
||||
uint8_t data[], uint32_t size, uint32_t &offset,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue