From b4e4e1cf5e091a1bce0b5ccb8f1910753eff0132 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 12 Dec 2020 10:00:49 -0500 Subject: [PATCH] Use wxFFile instead of wxFile for saving json settings/json_settings.cpp wxFile is dangerous, it's ::Write method is a direct map to the write syscall. It does not handle partial writes! This must be handled in our code which we don't. --- common/settings/json_settings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index a3a6ba7a77..1bc5aa533a 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -33,6 +33,8 @@ #include #include #include +#include + const wxChar* const traceSettings = wxT( "KICAD_SETTINGS" ); @@ -390,7 +392,7 @@ bool JSON_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce ) std::stringstream buffer; buffer << std::setw( 2 ) << *this << std::endl; - wxFile file( path.GetFullPath(), wxFile::write ); + wxFFile file( path.GetFullPath(), "wb" ); if( !file.IsOpened() || !file.Write( buffer.str().c_str(), buffer.str().size() ) ) {