From 5061046c962d532ca4051ab9fed461c82c4a3206 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 19 Mar 2016 18:58:00 +0100 Subject: [PATCH 1/4] Add Plugins Path for Apple From Jenster --- libretroshare/src/rsserver/rsinit.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index abaacc2d5..6c32438ff 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1258,6 +1258,9 @@ int RsServer::StartupRetroShare() std::vector plugins_directories ; +#ifdef __APPLE__ + plugins_directories.push_back(rsAccounts->PathDataDirectory()) ; +#endif #ifndef WINDOWS_SYS plugins_directories.push_back(std::string(PLUGIN_DIR)) ; #endif From 2e9d22c580095bae871a877ea7a8bcdcd40570c5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 19 Mar 2016 18:47:46 -0400 Subject: [PATCH 2/4] used RsTemporaryMemory to avoid memory leak in case of error in GxsTunnels --- libretroshare/src/gxstunnel/p3gxstunnel.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index d428a7ae8..3fd298674 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -763,15 +763,19 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t uint32_t encrypted_size = data_size - GXS_TUNNEL_ENCRYPTION_IV_SIZE - GXS_TUNNEL_ENCRYPTION_HMAC_SIZE; uint32_t decrypted_size = RsAES::get_buffer_size(encrypted_size); uint8_t *encrypted_data = (uint8_t*)data_bytes+GXS_TUNNEL_ENCRYPTION_IV_SIZE+GXS_TUNNEL_ENCRYPTION_HMAC_SIZE; - uint8_t *decrypted_data = new uint8_t[decrypted_size]; + + RsTemporaryMemory decrypted_data(decrypted_size); uint8_t aes_key[GXS_TUNNEL_AES_KEY_SIZE] ; + + if(!decrypted_data) + return false ; std::map::iterator it = _gxs_tunnel_virtual_peer_ids.find(virtual_peer_id) ; if(it == _gxs_tunnel_virtual_peer_ids.end()) { std::cerr << "(EE) item is not coming out of a registered tunnel. Weird. hash=" << hash << ", peer id = " << virtual_peer_id << std::endl; - return true ; + return false ; } tunnel_id = it->second.tunnel_id ; @@ -780,7 +784,7 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t if(it2 == _gxs_tunnel_contacts.end()) { std::cerr << "(EE) no tunnel data for tunnel ID=" << tunnel_id << ". This is a bug." << std::endl; - return true ; + return false ; } memcpy(aes_key,it2->second.aes_key,GXS_TUNNEL_AES_KEY_SIZE) ; @@ -800,8 +804,6 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t std::cerr << "(EE) packet HMAC does not match. Computed HMAC=" << RsUtil::BinToHex((char*)hm,GXS_TUNNEL_ENCRYPTION_HMAC_SIZE) << std::endl; std::cerr << "(EE) resetting new DH session." << std::endl; - delete[] decrypted_data ; - locked_restartDHSession(virtual_peer_id,it2->second.own_gxs_id) ; return false ; @@ -812,8 +814,6 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t std::cerr << "(EE) packet decryption failed." << std::endl; std::cerr << "(EE) resetting new DH session." << std::endl; - delete[] decrypted_data ; - locked_restartDHSession(virtual_peer_id,it2->second.own_gxs_id) ; return false ; @@ -829,8 +829,6 @@ bool p3GxsTunnelService::handleEncryptedData(const uint8_t *data_bytes,uint32_t // citem = dynamic_cast(RsGxsTunnelSerialiser().deserialise(decrypted_data,&decrypted_size)) ; - delete[] decrypted_data ; - if(citem == NULL) { std::cerr << "(EE) item could not be de-serialized. That is an error." << std::endl; From b13292bb804bc1f932e2fae597a3aef9e1e92298 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sun, 20 Mar 2016 12:10:56 +0100 Subject: [PATCH 3/4] Fix error reported by CppChecker: /libretroshare/src/gxs/rsgenexchange.cc:2850: erreur : Cppcheck: Dereferencing 'grp' after it is deallocated / released /libretroshare/src/gxstunnel/p3gxstunnel.cc:1004: erreur : Cppcheck: Invalid usage of output stream: '<< std::cerr'. /libretroshare/src/util/contentvalue.cc:185: erreur : Cppcheck: Memory leak: dest /openpgpsdk/src/openpgpsdk/reader_armoured.c:575: erreur : Cppcheck: Common realloc mistake: 'buf' nulled but not freed upon failure /retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp:103: erreur : Cppcheck: Array 'byteUnits[4]' accessed at index 4, which is out of bounds. /retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp:122: erreur : Cppcheck: Array 'byteUnits[4]' accessed at index 4, which is out of bounds. /retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp:141: erreur : Cppcheck: Array 'byteUnits[4]' accessed at index 4, which is out of bounds. /retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp:92: erreur : Cppcheck: Array 'byteUnits[4]' accessed at index 4, which is out of bounds. /retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp:111: erreur : Cppcheck: Array 'byteUnits[4]' accessed at index 4, which is out of bounds. /retroshare-gui/src/gui/People/PeopleDialog.cpp:774: erreur : Cppcheck: Uninitialized variable: layout /retroshare-gui/src/gui/People/PeopleDialog.cpp:864: erreur : Cppcheck: Uninitialized variable: layout /retroshare-gui/src/gui/common/AvatarWidget.cpp:225: erreur : Cppcheck: Uninitialized variable: status /retroshare-nogui/src/rpc/proto/rpcprotostream.cc:805: erreur : Cppcheck: Memory leak: buffer /supportlibs/pegmarkdown/GLibFacade.c:150: erreur : Cppcheck: va_list 'args' was opened but not closed by va_end(). /openpgpsdk/src/openpgpsdk/reader_armoured.c:575: erreur : Cppcheck: Common realloc mistake: 'buf' nulled but not freed upon failure /tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc:213: erreur : Cppcheck: Return value of allocation function 'init_item' is not stored. --- libretroshare/src/gxs/rsgenexchange.cc | 4 ++-- libretroshare/src/gxstunnel/p3gxstunnel.cc | 2 +- libretroshare/src/util/contentvalue.cc | 1 + openpgpsdk/src/openpgpsdk/reader_armoured.c | 10 +++++++++- retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp | 6 +++--- retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp | 4 ++-- retroshare-gui/src/gui/People/PeopleDialog.cpp | 4 ++-- retroshare-gui/src/gui/common/AvatarWidget.cpp | 2 +- retroshare-nogui/src/rpc/proto/rpcprotostream.cc | 1 + supportlibs/pegmarkdown/GLibFacade.c | 1 + .../libretroshare/serialiser/rsturtleitem_test.cc | 3 +-- 11 files changed, 24 insertions(+), 14 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 4ac595908..5536bad28 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2844,11 +2844,11 @@ void RsGenExchange::processRecvdGroups() if(gpsi.mAttempts == VALIDATE_MAX_ATTEMPTS) { - delete grp; - erase = true; #ifdef GEN_EXCH_DEBUG std::cerr << " max attempts " << VALIDATE_MAX_ATTEMPTS << " reached. Will delete group " << grp->grpId << std::endl; #endif + delete grp; + erase = true; } else { diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 3fd298674..454efb509 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -1001,7 +1001,7 @@ void p3GxsTunnelService::handleRecvDHPublicKey(RsGxsTunnelDHPublicKeyItem *item) #ifdef DEBUG_GXS_TUNNEL std::cerr << " DH key computed. Tunnel is now secured!" << std::endl; - std::cerr << " Key computed: " << RsUtil::BinToHex((char*)pinfo.aes_key,16) << std::cerr << std::endl; + std::cerr << " Key computed: " << RsUtil::BinToHex((char*)pinfo.aes_key,16) << std::endl; std::cerr << " Sending a ACK packet." << std::endl; #endif diff --git a/libretroshare/src/util/contentvalue.cc b/libretroshare/src/util/contentvalue.cc index 23f833cfc..fa8d616a1 100644 --- a/libretroshare/src/util/contentvalue.cc +++ b/libretroshare/src/util/contentvalue.cc @@ -182,6 +182,7 @@ void ContentValue::put(const std::string &key, uint32_t len, const char* value){ mKvData.insert(std::pair > (key, std::pair(len, dest))); + //delete[] dest; //Deleted by clearData() } bool ContentValue::getAsBool(const std::string &key, bool& value) const{ diff --git a/openpgpsdk/src/openpgpsdk/reader_armoured.c b/openpgpsdk/src/openpgpsdk/reader_armoured.c index 47339b4b6..361bfc62b 100644 --- a/openpgpsdk/src/openpgpsdk/reader_armoured.c +++ b/openpgpsdk/src/openpgpsdk/reader_armoured.c @@ -572,7 +572,15 @@ static int parse_headers(dearmour_arg_t *arg,ops_error_t **errors, if(size <= nbuf+1) { size+=size+80; - buf=realloc(buf,size); + char *nbuf; + nbuf=realloc(buf,size); + if (nbuf == NULL) + { + free(buf); + rtn=-1; + goto end; + } + buf = nbuf; } buf[nbuf++]=c; } diff --git a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp index b55d9b2f1..9da53d50c 100644 --- a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp @@ -96,7 +96,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { multi = 1.0; - for(int i = 0; i < 5; ++i) { + for(int i = 0; i < 4; ++i) { if (fileSize < 1024) { fileSize = index.data().toLongLong(); temp.sprintf("%.2f ", fileSize / multi); @@ -115,7 +115,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { multi = 1.0; - for(int i = 0; i < 5; ++i) { + for(int i = 0; i < 4; ++i) { if (remaining < 1024) { remaining = index.data().toLongLong(); temp.sprintf("%.2f ", remaining / multi); @@ -134,7 +134,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { multi = 1.0; - for(int i = 0; i < 5; ++i) { + for(int i = 0; i < 4; ++i) { if (completed < 1024) { completed = index.data().toLongLong(); temp.sprintf("%.2f ", completed / multi); diff --git a/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp b/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp index 6613a065a..6a6f58c2c 100644 --- a/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp +++ b/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp @@ -85,7 +85,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { multi = 1.0; - for(int i = 0; i < 5; ++i) { + for(int i = 0; i < 4; ++i) { if (fileSize < 1024) { fileSize = index.data().toLongLong(); temp.sprintf("%.2f ", fileSize / multi); @@ -104,7 +104,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { multi = 1.0; - for(int i = 0; i < 5; ++i) { + for(int i = 0; i < 4; ++i) { if (transferred < 1024) { transferred = index.data().toLongLong(); temp.sprintf("%.2f ", transferred / multi); diff --git a/retroshare-gui/src/gui/People/PeopleDialog.cpp b/retroshare-gui/src/gui/People/PeopleDialog.cpp index e2289f987..6740bef66 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.cpp +++ b/retroshare-gui/src/gui/People/PeopleDialog.cpp @@ -768,7 +768,7 @@ void PeopleDialog::pf_dropEventOccursExt(QDropEvent *event) QWidget *wid = qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout; + FlowLayout *layout = NULL; if (wid) layout = qobject_cast(wid->layout()); if (layout) { @@ -858,7 +858,7 @@ void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event) QWidget *wid = qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout; + FlowLayout *layout = NULL; if (wid) layout = qobject_cast(wid->layout()); if (layout) { diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 3d7ac5275..1c02e7593 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -177,7 +177,7 @@ void AvatarWidget::refreshStatus() } case STATUS_FRAME: { - uint32_t status ; + uint32_t status = 0; if(mId.isNotSet()) return ; diff --git a/retroshare-nogui/src/rpc/proto/rpcprotostream.cc b/retroshare-nogui/src/rpc/proto/rpcprotostream.cc index 445d5136a..37980ba2d 100644 --- a/retroshare-nogui/src/rpc/proto/rpcprotostream.cc +++ b/retroshare-nogui/src/rpc/proto/rpcprotostream.cc @@ -802,6 +802,7 @@ bool fill_stream_data(rsctrl::stream::StreamData &data, const RpcStream &stream) { std::cerr << "fill_stream_data() Failed to get data. data_size=" << data_size << ", base_loc=" << base_loc << " !"; std::cerr << std::endl; + free(buffer); return false; } diff --git a/supportlibs/pegmarkdown/GLibFacade.c b/supportlibs/pegmarkdown/GLibFacade.c index ab1438814..bd594787d 100644 --- a/supportlibs/pegmarkdown/GLibFacade.c +++ b/supportlibs/pegmarkdown/GLibFacade.c @@ -147,6 +147,7 @@ void g_string_append_printf(GString* baseString, char* format, ...) g_string_append(baseString, formattedString); free(formattedString); } + va_end(args); } void g_string_prepend(GString* baseString, char* prependedString) diff --git a/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc b/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc index eff26d032..55a6add4b 100644 --- a/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc +++ b/tests/unittests/libretroshare/serialiser/rsturtleitem_test.cc @@ -187,12 +187,11 @@ bool operator==(const RsTurtleStringSearchRequestItem& it1,const RsTurtleStringS return false ; return true ; } -RsSerialType* init_item(TurtleFileInfo& info) +void init_item(TurtleFileInfo& info) { info.hash = RsFileHash("3f753e8ac3b94ab9fddfad94480f747bf4418370"); info.name = "toto.png"; info.size = 0x3392085443897ull ; - return new RsTurtleSerialiser(); } bool operator==(const TurtleFileInfo& it1,const TurtleFileInfo& it2) { From c627e1bfb726fae43356970900fdef1f2a17989a Mon Sep 17 00:00:00 2001 From: dartraiden Date: Sun, 20 Mar 2016 19:27:28 +0300 Subject: [PATCH 4/4] Fix typo --- retroshare-gui/src/gui/common/FriendList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 3dbdfdd13..d7caa0176 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -1818,7 +1818,7 @@ bool FriendList::importExportFriendlistFileDialog(QString &fileName, bool import { if(!misc::getSaveFileName(this, RshareSettings::LASTDIR_CERT, - (import ? tr("Select file for importing yoour friendlist from") : + (import ? tr("Select file for importing your friendlist from") : tr("Select a file for exporting your friendlist to")), tr("XML File (*.xml);;All Files (*)"), fileName,