From 1994dfa31a3e1d6a2cf726ac86718d9484095233 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 8 Aug 2013 18:59:35 +0000 Subject: [PATCH] fixed looping in pqistore when a crazily long packet is found. That is the result of an unknown bug, but at least we should handle it correctly. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6568 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 548f4e830..35353e381 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -306,7 +306,11 @@ int pqistore::readPkt(RsItem **item_out) int extralen = getRsItemSize(block) - blen; if(extralen+blen > maxlen) + { + free(block) ; std::cerr << "***** ERROR: trying to read a packet of length " << extralen+blen << ", while the maximum length is " << maxlen << std::endl ; + return 0 ; + } if (extralen > 0) { @@ -496,7 +500,11 @@ int pqiSSLstore::readPkt(RsItem **item_out) int extralen = getRsItemSize(block) - blen; if(extralen+blen > maxlen) + { + free(block) ; std::cerr << "***** ERROR: trying to read a packet of length " << extralen+blen << ", while the maximum length is " << maxlen << std::endl ; + return 0 ; + } if (extralen > 0) {