From 4aafdfd1c6ee76484b83a4e91a73af357aba0de7 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 2 Apr 2015 21:21:21 -0400 Subject: add catch for possible exception in llsechandler_basic destructor (crash on exit) --- indra/newview/llsechandler_basic.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'indra/newview/llsechandler_basic.cpp') diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index fc9d9f0842..588c585f52 100755 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -1364,6 +1364,7 @@ void LLSecAPIBasicHandler::_writeProtectedData() } catch (...) { + LL_WARNS() << "LLProtectedDataException(Error writing Protected Data Store)" << LL_ENDL; // it's good practice to clean up any secure information on error // (even though this file isn't really secure. Perhaps in the future // it may be, however. @@ -1372,20 +1373,35 @@ void LLSecAPIBasicHandler::_writeProtectedData() // EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData() // Decided throwing an exception here was overkill until we figure out why this happens //throw LLProtectedDataException("Error writing Protected Data Store"); - LL_INFOS() << "LLProtectedDataException(Error writing Protected Data Store)" << LL_ENDL; } - // move the temporary file to the specified file location. - if((((LLFile::isfile(mProtectedDataFilename) != 0) && - (LLFile::remove(mProtectedDataFilename) != 0))) || - (LLFile::rename(tmp_filename, mProtectedDataFilename))) + try + { + // move the temporary file to the specified file location. + if((( (LLFile::isfile(mProtectedDataFilename) != 0) + && (LLFile::remove(mProtectedDataFilename) != 0))) + || (LLFile::rename(tmp_filename, mProtectedDataFilename))) + { + LL_WARNS() << "LLProtectedDataException(Could not overwrite protected data store)" << LL_ENDL; + LLFile::remove(tmp_filename); + + // EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData() + // Decided throwing an exception here was overkill until we figure out why this happens + //throw LLProtectedDataException("Could not overwrite protected data store"); + } + } + catch (...) { + LL_WARNS() << "LLProtectedDataException(Error renaming '" << tmp_filename + << "' to '" << mProtectedDataFilename << "')" << LL_ENDL; + // it's good practice to clean up any secure information on error + // (even though this file isn't really secure. Perhaps in the future + // it may be, however. LLFile::remove(tmp_filename); - // EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData() + //crash in LLSecAPIBasicHandler::_writeProtectedData() // Decided throwing an exception here was overkill until we figure out why this happens - //throw LLProtectedDataException("Could not overwrite protected data store"); - LL_INFOS() << "LLProtectedDataException(Could not overwrite protected data store)" << LL_ENDL; + //throw LLProtectedDataException("Error writing Protected Data Store"); } } -- cgit v1.2.3 From 3a57b18896eacb6fea6680d0eccaaeddb0b700b0 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 7 Apr 2015 17:28:05 -0400 Subject: convert llifstream and llofstream to std::ifstream and std::ofstream respectively --- indra/newview/llsechandler_basic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsechandler_basic.cpp') diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index 588c585f52..40516f9bbb 100755 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -640,7 +640,7 @@ LLBasicCertificateStore::~LLBasicCertificateStore() // persist the store void LLBasicCertificateStore::save() { - llofstream file_store(mFilename, llofstream::binary); + llofstream file_store(mFilename.c_str(), std::ios_base::binary); if(!file_store.fail()) { for(iterator cert = begin(); @@ -1331,7 +1331,7 @@ void LLSecAPIBasicHandler::_writeProtectedData() std::string tmp_filename = mProtectedDataFilename + ".tmp"; llofstream protected_data_stream(tmp_filename.c_str(), - llofstream::binary); + std::ios_base::binary); try { @@ -1568,7 +1568,7 @@ std::string LLSecAPIBasicHandler::_legacyLoadPassword() { const S32 HASHED_LENGTH = 32; std::vector buffer(HASHED_LENGTH); - llifstream password_file(mLegacyPasswordPath, llifstream::binary); + llifstream password_file(mLegacyPasswordPath.c_str(), llifstream::binary); if(password_file.fail()) { -- cgit v1.2.3 From 8b42c7898ef756a4a81daa08b2a5acce2894f4b8 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 7 Apr 2015 17:59:28 -0400 Subject: replace llifstream and llofstream with std::ifstream and std::ofstream respectively --- indra/newview/llsechandler_basic.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsechandler_basic.cpp') diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index 40516f9bbb..c904b95666 100755 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -640,7 +640,7 @@ LLBasicCertificateStore::~LLBasicCertificateStore() // persist the store void LLBasicCertificateStore::save() { - llofstream file_store(mFilename.c_str(), std::ios_base::binary); + std::ofstream file_store(mFilename.c_str(), std::ios_base::binary); if(!file_store.fail()) { for(iterator cert = begin(); @@ -1245,8 +1245,8 @@ void LLSecAPIBasicHandler::_readProtectedData() { // attempt to load the file into our map LLPointer parser = new LLSDXMLParser(); - llifstream protected_data_stream(mProtectedDataFilename.c_str(), - llifstream::binary); + std::ifstream protected_data_stream(mProtectedDataFilename.c_str(), + std::ifstream::binary); if (!protected_data_stream.fail()) { U8 salt[STORE_SALT_SIZE]; @@ -1330,7 +1330,7 @@ void LLSecAPIBasicHandler::_writeProtectedData() // an error. std::string tmp_filename = mProtectedDataFilename + ".tmp"; - llofstream protected_data_stream(tmp_filename.c_str(), + std::ofstream protected_data_stream(tmp_filename.c_str(), std::ios_base::binary); try { @@ -1568,7 +1568,7 @@ std::string LLSecAPIBasicHandler::_legacyLoadPassword() { const S32 HASHED_LENGTH = 32; std::vector buffer(HASHED_LENGTH); - llifstream password_file(mLegacyPasswordPath.c_str(), llifstream::binary); + std::ifstream password_file(mLegacyPasswordPath.c_str(), std::ifstream::binary); if(password_file.fail()) { -- cgit v1.2.3 From 5c6cf3e7fb9f592e3a293921175b64b515bac23f Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 10 Apr 2015 11:02:37 -0400 Subject: restore the ll[io]fstream because we need them as wrappers on Windows for wide char paths; on other platforms they are now just typedefs to the std classes --- indra/newview/llsechandler_basic.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llsechandler_basic.cpp') diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index c904b95666..40516f9bbb 100755 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -640,7 +640,7 @@ LLBasicCertificateStore::~LLBasicCertificateStore() // persist the store void LLBasicCertificateStore::save() { - std::ofstream file_store(mFilename.c_str(), std::ios_base::binary); + llofstream file_store(mFilename.c_str(), std::ios_base::binary); if(!file_store.fail()) { for(iterator cert = begin(); @@ -1245,8 +1245,8 @@ void LLSecAPIBasicHandler::_readProtectedData() { // attempt to load the file into our map LLPointer parser = new LLSDXMLParser(); - std::ifstream protected_data_stream(mProtectedDataFilename.c_str(), - std::ifstream::binary); + llifstream protected_data_stream(mProtectedDataFilename.c_str(), + llifstream::binary); if (!protected_data_stream.fail()) { U8 salt[STORE_SALT_SIZE]; @@ -1330,7 +1330,7 @@ void LLSecAPIBasicHandler::_writeProtectedData() // an error. std::string tmp_filename = mProtectedDataFilename + ".tmp"; - std::ofstream protected_data_stream(tmp_filename.c_str(), + llofstream protected_data_stream(tmp_filename.c_str(), std::ios_base::binary); try { @@ -1568,7 +1568,7 @@ std::string LLSecAPIBasicHandler::_legacyLoadPassword() { const S32 HASHED_LENGTH = 32; std::vector buffer(HASHED_LENGTH); - std::ifstream password_file(mLegacyPasswordPath.c_str(), std::ifstream::binary); + llifstream password_file(mLegacyPasswordPath.c_str(), llifstream::binary); if(password_file.fail()) { -- cgit v1.2.3