mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
improved error handlign in pqistore
This commit is contained in:
parent
8f97647246
commit
77c2e6da8c
@ -310,24 +310,25 @@ int pqistore::readPkt(RsItem **item_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// workout how much more to read.
|
// workout how much more to read.
|
||||||
int extralen = getRsItemSize(block) - blen;
|
int blocklength = getRsItemSize(block);
|
||||||
int totallen = extralen+blen;
|
|
||||||
|
|
||||||
// make sure that totallen is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
// make sure that blocklength is not a crazy number. If so, we drop the entire stream that might be corrupted.
|
||||||
|
|
||||||
if(totallen > 1024*1024)
|
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||||
{
|
{
|
||||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen <<", which exceeds the allowed limit (1MB)" << std::endl ;
|
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength <<", which is either too small, or exceeds the safety limit (10 MB)" << std::endl ;
|
||||||
free(block) ;
|
free(block) ;
|
||||||
bStopReading=true;
|
bStopReading=true;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
void *tmp = realloc(block, totallen);
|
int extralen = blocklength - blen;
|
||||||
|
|
||||||
|
void *tmp = realloc(block, blocklength);
|
||||||
|
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
{
|
{
|
||||||
free(block);
|
free(block);
|
||||||
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << totallen << std::endl ;
|
std::cerr << "pqistore: ERROR: trying to realloc memory for packet of length" << blocklength << std::endl ;
|
||||||
std::cerr << "Have you got enought memory?" << std::endl ;
|
std::cerr << "Have you got enought memory?" << std::endl ;
|
||||||
bStopReading=true;
|
bStopReading=true;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
@ -522,17 +523,18 @@ int pqiSSLstore::readPkt(RsItem **item_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// workout how much more to read.
|
// workout how much more to read.
|
||||||
int extralen = getRsItemSize(block) - blen;
|
int blocklength = getRsItemSize(block);
|
||||||
int totallen = extralen+blen;
|
|
||||||
|
|
||||||
if(totallen > 1024*1024 || totallen<blen)
|
if(blocklength < blen || blocklength > 1024*1024*10)
|
||||||
{
|
{
|
||||||
free(block);
|
free(block);
|
||||||
std::cerr << "pqiSSLstore: ERROR: trying to realloc memory for packet of length" << totallen << ", that exceeds the limit of 1MB" << std::endl ;
|
std::cerr << "pqiSSLstore: ERROR: block length has invalid value " << blocklength << " (either too small, or exceeds the safety limit of 10 MB)" << std::endl ;
|
||||||
bStopReading=true;
|
bStopReading=true;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
void *tmp = realloc(block, totallen);
|
int extralen = blocklength - blen;
|
||||||
|
|
||||||
|
void *tmp = realloc(block, blocklength);
|
||||||
|
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user