added security check against malformed packets

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2764 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-04-23 12:57:59 +00:00
parent c4de9f0219
commit 695226301a

View File

@ -333,7 +333,15 @@ int pqistore::readPkt(RsItem **item_out)
int extralen = getRsItemSize(block) - blen;
if (extralen > 0)
{
if(extralen > blen + maxlen)
{
std::cerr << "pqistore: ERROR: Inconsistency in packet format (extralen=" << extralen << ", maxlen=" << maxlen << "). Wasting the whole file." << std::endl ;
free(block) ;
return 0 ;
}
void *extradata = (void *) (((char *) block) + blen);
if (extralen != (tmplen = bio->readdata(extradata, extralen)))
{