added security check against malformed packets

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2763 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-04-23 12:57:39 +00:00
parent 3cca133e1c
commit f04535522f

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)))
{