diff options
author | Tobias Markmann <tm@ayena.de> | 2015-03-08 16:22:02 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-05-01 17:36:17 (GMT) |
commit | 08f08513e636a8eb36645fdd712105156a754ae2 (patch) | |
tree | 53eb638fa47cb3a58f8c4f3ef3ab88a4e2b77ad6 | |
parent | f9dcd7a6e81e6c244e111aa1a22992f0604d999c (diff) | |
download | swift-08f08513e636a8eb36645fdd712105156a754ae2.zip swift-08f08513e636a8eb36645fdd712105156a754ae2.tar.bz2 |
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
-rw-r--r-- | Swiften/FileTransfer/IncomingJingleFileTransfer.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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; } } |