From 08f08513e636a8eb36645fdd712105156a754ae2 Mon Sep 17 00:00:00 2001 From: Tobias Markmann <tm@ayena.de> Date: Sun, 8 Mar 2015 17:22:02 +0100 Subject: Fix hash verification in Jingle FT to only verify one hash algorithm This also adds missing resets pointers to NULL after they are deleted. Test-Information: FileTransferTest crashed in some scenarios before; now it always runs successful. Change-Id: Ic63fd51eeb46e708221a04dc912e8bf2f1d4f9fb diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp index a0cd47c..98ad4d3 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp @@ -140,7 +140,7 @@ void IncomingJingleFileTransfer::handleSessionInfoReceived(JinglePayload::ref ji if (transferHash->getFileInfo().getHashes().find("sha-1") != transferHash->getFileInfo().getHashes().end()) { hashes["sha-1"] = transferHash->getFileInfo().getHash("sha-1").get(); } - else if (transferHash->getFileInfo().getHashes().find("md5") != transferHash->getFileInfo().getHashes().end()) { + if (transferHash->getFileInfo().getHashes().find("md5") != transferHash->getFileInfo().getHashes().end()) { hashes["md5"] = transferHash->getFileInfo().getHash("md5").get(); } if (state == WaitingForHash) { @@ -186,9 +186,9 @@ void IncomingJingleFileTransfer::checkHashAndTerminate() { void IncomingJingleFileTransfer::checkIfAllDataReceived() { if (receivedBytes == getFileSizeInBytes()) { SWIFT_LOG(debug) << "All data received." << std::endl; - bool hashInfoAvailable = true; + bool hashInfoAvailable = false; foreach(const JingleFileTransferFileInfo::HashElementMap::value_type& hashElement, hashes) { - hashInfoAvailable &= !hashElement.second.empty(); + hashInfoAvailable |= !hashElement.second.empty(); } if (!hashInfoAvailable) { @@ -314,6 +314,7 @@ void IncomingJingleFileTransfer::stopAll() { if (state != Initial) { writeStreamDataReceivedConnection.disconnect(); delete hashCalculator; + hashCalculator = NULL; } switch (state) { case Initial: break; @@ -333,6 +334,7 @@ void IncomingJingleFileTransfer::stopAll() { } if (state != Initial) { delete transporter; + transporter = NULL; } } -- cgit v0.10.2-6-g49f6