From 0fd8b4d4eeff05427f622f65608872499e7d914e Mon Sep 17 00:00:00 2001 From: joss17 Date: Mon, 15 Mar 2010 19:11:33 +0000 Subject: [PATCH] improve the recieving of bad gpg keys Conflicts: libretroshare/src/services/p3disc.cc git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2555 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 12 ++++++++++-- libretroshare/src/services/p3disc.cc | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index c36235dc2..77f9fba73 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -1179,17 +1179,25 @@ bool AuthGPG::LoadCertificateFromString(std::string str, std::string &gpg_id) RsStackMutex stack(pgpMtx); /******* LOCKED ******/ + if (str == "") { + #ifdef GPG_DEBUG + std::cerr << "AuthGPG::LoadCertificateFromString() cert is empty string, returning false." << std::endl; + #endif + return false; + } + //std::string cleancert = cleanUpCertificate(str); disable for p3disc message on windows system. Move the clean cert in p3peers std::string cleancert = str; -#ifdef GPG_DEBUG + #ifdef GPG_DEBUG std::cerr << "AuthGPG::LoadCertificateFromString() cleancert : " << cleancert; -#endif + #endif gpgme_data_t gpgmeData; if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeData, cleancert.c_str(), cleancert.length(), 1)) { std::cerr << "Error create Data" << std::endl; + return false; } /* move string data to gpgmeData */ diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index b7f5f111f..1f7eb59af 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -509,7 +509,12 @@ void p3disc::recvPeerDetails(RsDiscReply *item) std::cerr << "p3disc::recvPeerFriendMsg() From: " << item->PeerId() << " About " << item->aboutId << std::endl; #endif std::string certGpgId; - AuthGPG::getAuthGPG()->LoadCertificateFromString(item->certGPG, certGpgId); + if (!AuthGPG::getAuthGPG()->LoadCertificateFromString(item->certGPG, certGpgId)) { + #ifdef P3DISC_DEBUG + std::cerr << "p3disc::recvPeerFriendMsg() gpg cert is not good, aborting" << std::endl; + #endif + return; + } if (item->aboutId == "" || item->aboutId != certGpgId) { #ifdef P3DISC_DEBUG std::cerr << "p3disc::recvPeerFriendMsg() Error : about id is not the same as gpg id." << std::endl;