mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-25 17:39:18 -04:00
fixed a few things to correct PR403
This commit is contained in:
parent
699b3cf064
commit
10e0254317
@ -532,12 +532,18 @@ bool RsGRouterTransactionAcknItem::serialise(void *data,uint32_t& size) const
|
|||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
bool RsGRouterGenericDataItem::serialise_signed_data(void *data,uint32_t& size) const
|
bool RsGRouterGenericDataItem::serialise_signed_data(void *data,uint32_t size) const
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
uint32_t tlvsize = signed_data_size() ;
|
uint32_t tlvsize = signed_data_size() ;
|
||||||
|
|
||||||
|
if(tlvsize > size)
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
std::cerr << "RsGRouterReceiptItem::serialisedata() size error! Not enough size in supplied container." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= setRawUInt64(data, tlvsize, &offset, routing_id);
|
ok &= setRawUInt64(data, tlvsize, &offset, routing_id);
|
||||||
@ -580,12 +586,18 @@ bool RsGRouterSignedReceiptItem::serialise(void *data,uint32_t& size) const
|
|||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
bool RsGRouterSignedReceiptItem::serialise_signed_data(void *data,uint32_t& size) const
|
bool RsGRouterSignedReceiptItem::serialise_signed_data(void *data,uint32_t size) const
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
uint32_t offset=0;
|
uint32_t offset=0;
|
||||||
uint32_t tlvsize = signed_data_size() ;
|
uint32_t tlvsize = signed_data_size() ;
|
||||||
|
|
||||||
|
if(tlvsize > size)
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
std::cerr << "RsGRouterReceiptItem::serialisedata() size error! Not enough size in supplied container." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= setRawUInt64(data, tlvsize, &offset, routing_id);
|
ok &= setRawUInt64(data, tlvsize, &offset, routing_id);
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
virtual ~RsGRouterAbstractMsgItem() {}
|
virtual ~RsGRouterAbstractMsgItem() {}
|
||||||
|
|
||||||
virtual uint32_t signed_data_size() const = 0 ;
|
virtual uint32_t signed_data_size() const = 0 ;
|
||||||
virtual bool serialise_signed_data(void *data,uint32_t& size) const = 0 ;
|
virtual bool serialise_signed_data(void *data,uint32_t size) const = 0 ;
|
||||||
|
|
||||||
GRouterMsgPropagationId routing_id ;
|
GRouterMsgPropagationId routing_id ;
|
||||||
GRouterKeyId destination_key ;
|
GRouterKeyId destination_key ;
|
||||||
@ -137,7 +137,7 @@ class RsGRouterGenericDataItem: public RsGRouterAbstractMsgItem, public RsGRoute
|
|||||||
|
|
||||||
// utility methods for signing data
|
// utility methods for signing data
|
||||||
virtual uint32_t signed_data_size() const ;
|
virtual uint32_t signed_data_size() const ;
|
||||||
virtual bool serialise_signed_data(void *data,uint32_t& size) const ;
|
virtual bool serialise_signed_data(void *data, uint32_t size) const ;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
||||||
@ -160,7 +160,7 @@ class RsGRouterSignedReceiptItem: public RsGRouterAbstractMsgItem
|
|||||||
|
|
||||||
// utility methods for signing data
|
// utility methods for signing data
|
||||||
virtual uint32_t signed_data_size() const ;
|
virtual uint32_t signed_data_size() const ;
|
||||||
virtual bool serialise_signed_data(void *data,uint32_t& size) const ;
|
virtual bool serialise_signed_data(void *data, uint32_t size) const ;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Low-level data items
|
// Low-level data items
|
||||||
|
@ -289,7 +289,7 @@ bool RsGxsIntegrityCheck::check()
|
|||||||
|
|
||||||
// now request a cache update for them, which triggers downloading from friends, if missing.
|
// now request a cache update for them, which triggers downloading from friends, if missing.
|
||||||
|
|
||||||
for(;nb_requested_not_in_cache<MAX_GXS_IDS_REQUESTS_NET && gxs_ids.size()>0;)
|
for(;nb_requested_not_in_cache<MAX_GXS_IDS_REQUESTS_NET && !gxs_ids.empty();)
|
||||||
{
|
{
|
||||||
uint32_t n = RSRandom::random_u32() % gxs_ids.size() ;
|
uint32_t n = RSRandom::random_u32() % gxs_ids.size() ;
|
||||||
#ifdef GXSUTIL_DEBUG
|
#ifdef GXSUTIL_DEBUG
|
||||||
|
@ -378,6 +378,12 @@ RsGxsTunnelDataItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataItem(void
|
|||||||
uint32_t offset = 8; // skip the header
|
uint32_t offset = 8; // skip the header
|
||||||
uint32_t rssize = getRsItemSize(dat);
|
uint32_t rssize = getRsItemSize(dat);
|
||||||
bool ok = true ;
|
bool ok = true ;
|
||||||
|
|
||||||
|
if(rssize > size)
|
||||||
|
{
|
||||||
|
std::cerr << "RsGxsTunnelDataItem::() Size error while deserializing." << std::endl ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsTunnelDataItem *item = new RsGxsTunnelDataItem();
|
RsGxsTunnelDataItem *item = new RsGxsTunnelDataItem();
|
||||||
|
|
||||||
@ -388,9 +394,9 @@ RsGxsTunnelDataItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataItem(void
|
|||||||
ok &= getRawUInt32(dat, rssize, &offset, &item->service_id);
|
ok &= getRawUInt32(dat, rssize, &offset, &item->service_id);
|
||||||
ok &= getRawUInt32(dat, rssize, &offset, &item->data_size);
|
ok &= getRawUInt32(dat, rssize, &offset, &item->data_size);
|
||||||
|
|
||||||
if(item->data_size > rssize || rssize - item->data_size < offset)
|
if(item->data_size > rssize || rssize < offset + item->data_size)
|
||||||
{
|
{
|
||||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
std::cerr << "RsGxsTunnelDataItem::() Size error while deserializing." << std::endl ;
|
||||||
delete item ;
|
delete item ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
@ -456,6 +462,12 @@ RsGxsTunnelStatusItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelStatusItem(
|
|||||||
uint32_t rssize = getRsItemSize(dat);
|
uint32_t rssize = getRsItemSize(dat);
|
||||||
bool ok = true ;
|
bool ok = true ;
|
||||||
|
|
||||||
|
if(rssize > size)
|
||||||
|
{
|
||||||
|
std::cerr << "RsGxsTunnelStatusItem::() Size error while deserializing." << std::endl ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsTunnelStatusItem *item = new RsGxsTunnelStatusItem();
|
RsGxsTunnelStatusItem *item = new RsGxsTunnelStatusItem();
|
||||||
|
|
||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
@ -464,13 +476,13 @@ RsGxsTunnelStatusItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelStatusItem(
|
|||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Size error while deserializing." << std::endl ;
|
std::cerr << "RsGxsTunnelStatusItem::() Size error while deserializing." << std::endl ;
|
||||||
delete item ;
|
delete item ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
std::cerr << "RsGxsTunnelDHPublicKeyItem::() Unknown error while deserializing." << std::endl ;
|
std::cerr << "RsGxsTunnelStatusItem::() Unknown error while deserializing." << std::endl ;
|
||||||
delete item ;
|
delete item ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,12 @@ public:
|
|||||||
uint32_t rssize = getRsItemSize(data);
|
uint32_t rssize = getRsItemSize(data);
|
||||||
bool ok = true ;
|
bool ok = true ;
|
||||||
|
|
||||||
|
if(rssize > size)
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": error while deserialising! Item will be dropped." << std::endl;
|
||||||
|
return NULL ;
|
||||||
|
}
|
||||||
|
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
|
ok &= getRawUInt32(data, rssize, &offset, &item->mServiceId);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->mServiceName);
|
||||||
|
@ -170,7 +170,7 @@ uint64_t BinFileInterface::bytecount()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BinFileInterface::getFileSize()
|
uint64_t BinFileInterface::getFileSize()
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -229,7 +229,14 @@ int BinEncryptedFileInterface::readdata(void* data, int len)
|
|||||||
if(!haveData) // read whole data for first call, or first call after close()
|
if(!haveData) // read whole data for first call, or first call after close()
|
||||||
{
|
{
|
||||||
|
|
||||||
encrypDataLen = BinFileInterface::getFileSize();
|
uint64_t encrypDataLen64 = BinFileInterface::getFileSize();
|
||||||
|
|
||||||
|
if(encrypDataLen64 > uint64_t(~(int)0))
|
||||||
|
{
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": cannot decrypt files of size > " << ~(int)0 << std::endl;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
encrypDataLen = (int)encrypDataLen64 ;
|
||||||
encryptedData = new char[encrypDataLen];
|
encryptedData = new char[encrypDataLen];
|
||||||
|
|
||||||
// make sure assign was successful
|
// make sure assign was successful
|
||||||
@ -245,12 +252,15 @@ int BinEncryptedFileInterface::readdata(void* data, int len)
|
|||||||
|
|
||||||
if((encrypDataLen > 0) && (encryptedData != NULL))
|
if((encrypDataLen > 0) && (encryptedData != NULL))
|
||||||
{
|
{
|
||||||
if(!AuthSSL::getAuthSSL()->decrypt((void*&)(this->data), sizeData, encryptedData, encrypDataLen))
|
int sizeDataInt = 0 ;
|
||||||
|
|
||||||
|
if(!AuthSSL::getAuthSSL()->decrypt((void*&)(this->data), sizeDataInt, encryptedData, encrypDataLen))
|
||||||
{
|
{
|
||||||
delete[] encryptedData;
|
delete[] encryptedData;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sizeData = sizeDataInt ;
|
||||||
haveData = true;
|
haveData = true;
|
||||||
delete[] encryptedData;
|
delete[] encryptedData;
|
||||||
}
|
}
|
||||||
|
@ -76,12 +76,12 @@ virtual RsFileHash gethash();
|
|||||||
virtual uint64_t bytecount();
|
virtual uint64_t bytecount();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int getFileSize();
|
virtual uint64_t getFileSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int bin_flags;
|
int bin_flags;
|
||||||
FILE *buf;
|
FILE *buf;
|
||||||
int size;
|
uint64_t size;
|
||||||
pqihash *hash;
|
pqihash *hash;
|
||||||
uint64_t bcount;
|
uint64_t bcount;
|
||||||
};
|
};
|
||||||
@ -127,7 +127,7 @@ private:
|
|||||||
|
|
||||||
char* data;
|
char* data;
|
||||||
bool haveData;
|
bool haveData;
|
||||||
int sizeData;
|
uint64_t sizeData;
|
||||||
uint64_t cpyCount;
|
uint64_t cpyCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1043,7 +1043,7 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
|
|||||||
|
|
||||||
bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
||||||
{
|
{
|
||||||
bool isUnprocessedPeers = false;
|
//bool isUnprocessedPeers = false;
|
||||||
|
|
||||||
if (cache.mIsExternal)
|
if (cache.mIsExternal)
|
||||||
{
|
{
|
||||||
@ -1086,7 +1086,7 @@ bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mIdentities->requestKey(pit->first, peers);
|
mIdentities->requestKey(pit->first, peers);
|
||||||
isUnprocessedPeers = true;
|
//isUnprocessedPeers = true;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_CIRCLES
|
#ifdef DEBUG_CIRCLES
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user