From f04535522f20819b266da9aa9769654905945ab9 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 23 Apr 2010 12:57:39 +0000 Subject: [PATCH] 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 --- libretroshare/src/pqi/pqistore.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libretroshare/src/pqi/pqistore.cc b/libretroshare/src/pqi/pqistore.cc index 957f075ee..ce73f04ac 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -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))) {