mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
disable file size sanity check when loading the wallet cache
This commit is contained in:
parent
a2cef8cba4
commit
5a412b7a3f
2 changed files with 4 additions and 4 deletions
|
@ -128,7 +128,7 @@ namespace file_io_utils
|
|||
|
||||
|
||||
inline
|
||||
bool load_file_to_string(const std::string& path_to_file, std::string& target_str)
|
||||
bool load_file_to_string(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WCHAR wide_path[1000];
|
||||
|
@ -139,7 +139,7 @@ namespace file_io_utils
|
|||
if (file_handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
DWORD file_size = GetFileSize(file_handle, NULL);
|
||||
if ((file_size == INVALID_FILE_SIZE) || (file_size > 1000000000)) {
|
||||
if ((file_size == INVALID_FILE_SIZE) || (uint64_t)file_size > (uint64_t)max_size) {
|
||||
CloseHandle(file_handle);
|
||||
return false;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace file_io_utils
|
|||
|
||||
std::ifstream::pos_type file_size = fstream.tellg();
|
||||
|
||||
if(file_size > 1000000000)
|
||||
if((uint64_t)file_size > (uint64_t)max_size) // ensure a large domain for comparison, and negative -> too large
|
||||
return false;//don't go crazy
|
||||
size_t file_size_t = static_cast<size_t>(file_size);
|
||||
|
||||
|
|
|
@ -3772,7 +3772,7 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
|
|||
{
|
||||
wallet2::cache_file_data cache_file_data;
|
||||
std::string buf;
|
||||
bool r = epee::file_io_utils::load_file_to_string(m_wallet_file, buf);
|
||||
bool r = epee::file_io_utils::load_file_to_string(m_wallet_file, buf, std::numeric_limits<size_t>::max());
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::file_read_error, m_wallet_file);
|
||||
|
||||
// try to read it as an encrypted cache
|
||||
|
|
Loading…
Reference in a new issue