Version in base suite: 0.4.8-1 Base version: freeorion_0.4.8-1 Target version: freeorion_0.4.8-1+deb10u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/f/freeorion/freeorion_0.4.8-1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/f/freeorion/freeorion_0.4.8-1+deb10u1.dsc changelog | 19 +++ patches/debian-bug-930417.patch | 147 +++++++++++++++++++++++++++++ patches/really-fix-debian-bug-930417.patch | 44 ++++++++ patches/series | 2 4 files changed, 212 insertions(+) diff -Nru freeorion-0.4.8/debian/changelog freeorion-0.4.8/debian/changelog --- freeorion-0.4.8/debian/changelog 2018-08-31 15:09:10.000000000 +0000 +++ freeorion-0.4.8/debian/changelog 2019-07-27 01:24:19.000000000 +0000 @@ -1,3 +1,22 @@ +freeorion (0.4.8-1+deb10u1) buster; urgency=medium + + * Backport "Fix save or load game crash" patch to Buster. + + -- Markus Koschany Sat, 27 Jul 2019 03:24:19 +0200 + +freeorion (0.4.8-3) unstable; urgency=medium + + * Really fix save or load game crash. (Closes: #930417) + + -- Markus Koschany Sun, 23 Jun 2019 01:52:26 +0200 + +freeorion (0.4.8-2) unstable; urgency=medium + + * Fix save or load game crash. Thanks to Michal Mauser for the report and + Bernhard Übelacker for the investigation. (Closes: #930417) + + -- Markus Koschany Sun, 16 Jun 2019 01:02:41 +0200 + freeorion (0.4.8-1) unstable; urgency=medium * New upstream version 0.4.8. diff -Nru freeorion-0.4.8/debian/patches/debian-bug-930417.patch freeorion-0.4.8/debian/patches/debian-bug-930417.patch --- freeorion-0.4.8/debian/patches/debian-bug-930417.patch 1970-01-01 00:00:00.000000000 +0000 +++ freeorion-0.4.8/debian/patches/debian-bug-930417.patch 2019-07-27 00:08:52.000000000 +0000 @@ -0,0 +1,147 @@ +From: Markus Koschany +Date: Sun, 16 Jun 2019 01:10:41 +0200 +Subject: debian-bug-930417 + +Bug-Debian: https://bugs.debian.org/930417 +Origin: https://github.com/freeorion/freeorion/pull/2366/commits/1e94e406fa309c60c4b68ef08b424b65a7bd0e4d +--- + server/SaveLoad.cpp | 70 +++++++++++++++++++++++++++++------------------------ + 1 file changed, 39 insertions(+), 31 deletions(-) + +diff --git a/server/SaveLoad.cpp b/server/SaveLoad.cpp +index ecb73a3..37614d7 100644 +--- a/server/SaveLoad.cpp ++++ b/server/SaveLoad.cpp +@@ -333,8 +333,13 @@ void LoadGame(const std::string& filename, ServerSaveGameData& server_save_game_ + if (!ifs) + throw std::runtime_error(UNABLE_TO_OPEN_FILE); + +- try { +- // first attempt binary deserialziation ++ std::string signature(5, '\0'); ++ if (!ifs.read(&signature[0], 5)) ++ throw std::runtime_error(UNABLE_TO_OPEN_FILE); ++ boost::iostreams::seek(ifs, 0, std::ios_base::beg); ++ ++ if (strncmp(signature.c_str(), "> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); +@@ -350,14 +355,10 @@ void LoadGame(const std::string& filename, ServerSaveGameData& server_save_game_ + Deserialize(ia, universe); + + DebugLogger() << "Done deserializing"; +- } catch (...) { +- // if binary deserialization failed, try more-portable XML deserialization +- +- // reset to start of stream (attempted binary serialization will have consumed some input...) +- boost::iostreams::seek(ifs, 0, std::ios_base::beg); +- ++ } else { + // create archive with (preallocated) buffer... + freeorion_xml_iarchive xia(ifs); ++ DebugLogger() << "Reading XML iarchive"; + // read from save file: uncompressed header serialized data, with compressed main archive string at end... + // deserialize uncompressed save header info + xia >> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); +@@ -458,18 +459,21 @@ void LoadGalaxySetupData(const std::string& filename, GalaxySetupData& galaxy_se + if (!ifs) + throw std::runtime_error(UNABLE_TO_OPEN_FILE); + +- try { +- // first attempt binary deserialziation ++ std::string signature(5, '\0'); ++ if (!ifs.read(&signature[0], 5)) ++ throw std::runtime_error(UNABLE_TO_OPEN_FILE); ++ boost::iostreams::seek(ifs, 0, std::ios_base::beg); ++ ++ if (strncmp(signature.c_str(), "> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); + ia >> BOOST_SERIALIZATION_NVP(galaxy_setup_data); + +- } catch(...) { +- // if binary deserialization failed, try more-portable XML deserialization +- +- // reset to start of stream (attempted binary serialization will have consumed some input...) +- boost::iostreams::seek(ifs, 0, std::ios_base::beg); ++ } else { ++ DebugLogger() << "Attempting XML deserialization..."; + freeorion_xml_iarchive ia(ifs); + + ia >> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); +@@ -498,8 +502,13 @@ void LoadPlayerSaveHeaderData(const std::string& filename, std::vector> BOOST_SERIALIZATION_NVP(ignored_galaxy_setup_data); + ia >> BOOST_SERIALIZATION_NVP(ignored_server_save_game_data); + ia >> BOOST_SERIALIZATION_NVP(player_save_header_data); +- +- } catch (...) { +- // if binary deserialization failed, try more-portable XML deserialization +- DebugLogger() << "Trying again with XML deserialization..."; +- +- // reset to start of stream (attempted binary serialization will have consumed some input...) +- boost::iostreams::seek(ifs, 0, std::ios_base::beg); ++ } else { ++ DebugLogger() << "Attempting XML deserialization..."; + freeorion_xml_iarchive ia(ifs); + + ia >> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); +@@ -521,6 +525,7 @@ void LoadPlayerSaveHeaderData(const std::string& filename, std::vector> BOOST_SERIALIZATION_NVP(ignored_server_save_game_data); + ia >> BOOST_SERIALIZATION_NVP(player_save_header_data); + } ++ + // skipping additional deserialization which is not needed for this function + DebugLogger() << "Done reading player save game data..."; + } catch (const std::exception& e) { +@@ -545,8 +550,14 @@ void LoadEmpireSaveGameData(const std::string& filename, std::map> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); +@@ -555,11 +566,8 @@ void LoadEmpireSaveGameData(const std::string& filename, std::map> BOOST_SERIALIZATION_NVP(ignored_player_save_header_data); + ia >> BOOST_SERIALIZATION_NVP(empire_save_game_data); + +- } catch (...) { +- // if binary deserialization failed, try more-portable XML deserialization +- +- // reset to start of stream (attempted binary serialization will have consumed some input...) +- boost::iostreams::seek(ifs, 0, std::ios_base::beg); ++ } else { ++ DebugLogger() << "Attempting XML deserialization..."; + freeorion_xml_iarchive ia(ifs); + + ia >> BOOST_SERIALIZATION_NVP(ignored_save_preview_data); diff -Nru freeorion-0.4.8/debian/patches/really-fix-debian-bug-930417.patch freeorion-0.4.8/debian/patches/really-fix-debian-bug-930417.patch --- freeorion-0.4.8/debian/patches/really-fix-debian-bug-930417.patch 1970-01-01 00:00:00.000000000 +0000 +++ freeorion-0.4.8/debian/patches/really-fix-debian-bug-930417.patch 2019-07-27 00:08:52.000000000 +0000 @@ -0,0 +1,44 @@ +From: Markus Koschany +Date: Sun, 23 Jun 2019 01:50:54 +0200 +Subject: really fix debian bug 930417 + +Bug-Upstream: https://github.com/freeorion/freeorion/issues/2406 +Origin: https://github.com/freeorion/freeorion/commit/3e840f8d747fd0e6a513f3ef0278d3931f813109 +--- + util/SaveGamePreviewUtils.cpp | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/util/SaveGamePreviewUtils.cpp b/util/SaveGamePreviewUtils.cpp +index b9d49df..92122b1 100644 +--- a/util/SaveGamePreviewUtils.cpp ++++ b/util/SaveGamePreviewUtils.cpp +@@ -65,7 +65,14 @@ namespace { + + DebugLogger() << "LoadSaveGamePreviewData: Loading preview from: " << path.string(); + try { +- try { ++ // read the first five letters of the stream and check if it is opening an xml file ++ std::string xxx5(5, ' '); ++ ifs.read(&xxx5[0], 5); ++ const std::string xml5{"> BOOST_SERIALIZATION_NVP(save_preview_data); + ia >> BOOST_SERIALIZATION_NVP(galaxy_setup_data); + +- } catch (...) { +- // if binary deserialization failed, try more-portable XML deserialization +- +- // reset to start of stream (attempted binary serialization will have consumed some input...) +- boost::iostreams::seek(ifs, 0, std::ios_base::beg); +- ++ } else { + DebugLogger() << "Deserializing XML data"; + freeorion_xml_iarchive ia(ifs); + ia >> BOOST_SERIALIZATION_NVP(save_preview_data); diff -Nru freeorion-0.4.8/debian/patches/series freeorion-0.4.8/debian/patches/series --- freeorion-0.4.8/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ freeorion-0.4.8/debian/patches/series 2019-07-27 00:08:52.000000000 +0000 @@ -0,0 +1,2 @@ +debian-bug-930417.patch +really-fix-debian-bug-930417.patch