From fb8c99b2d47e9cc43d0a2632f0176f2c3b5e7884 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 15 Dec 2019 19:43:31 +0100 Subject: [PATCH] Don't suppress IO errors when writing files * Close or flush streams explicitely so writing is not deferred * to catch errors in the right place * to avoid suppressing errors completely when writing would be deferred to the destructor invocation * Improve comments --- CMakeLists.txt | 2 +- io/passwordfile.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 736ec68..4b7f60c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files") set(META_VERSION_MAJOR 5) set(META_VERSION_MINOR 0) -set(META_VERSION_PATCH 1) +set(META_VERSION_PATCH 2) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) # add project files diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index 91767ca..a63bf25 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -507,6 +507,7 @@ void PasswordFile::write(PasswordFileSaveFlags options) if (!(options & PasswordFileSaveFlags::Encryption)) { // write data to file m_file.write(decryptedData.data(), static_cast(size)); + m_file.flush(); return; } @@ -560,6 +561,7 @@ void PasswordFile::write(PasswordFileSaveFlags options) } m_file.write(reinterpret_cast(iv), aes256cbcIvSize); m_file.write(encryptedData.data(), static_cast(outlen1 + outlen2)); + m_file.flush(); } /*!