From 86a7f1526b5f1500845440959da14ae642f54759 Mon Sep 17 00:00:00 2001 From: N2614 Date: Wed, 25 Jan 2012 01:18:42 +0000 Subject: [PATCH] =?UTF-8?q?BGS=E3=81=A8=E3=81=AE=E9=80=9A=E4=BF=A1?= =?UTF-8?q?=E7=B5=90=E6=9E=9C=E3=81=AFNULL=E7=B5=82=E7=AB=AF=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=8B=E3=82=89XML=E3=83=91=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=BF=85=E8=A6=81=E3=81=8C=E3=81=82=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@603 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleRestore/PreinstallImporter.cpp | 8 +++++--- .../BgsCommunicator/test_BgsCommunicator.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/PreinstallImporter.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/PreinstallImporter.cpp index 8bdac81..d9878ed 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/PreinstallImporter.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/PreinstallImporter.cpp @@ -82,18 +82,20 @@ nn::Result PreinstallImporter::GetHtmlBodyAndParseXmlData(BgsCommunicator& comm, { return comm.GetLastResult(); } - if(common::GetAllocatableSize() < bodySize) + if(common::GetAllocatableSize() < bodySize + 1) { // 巨大な通信結果のためFATAL。1回で受信しきれるはず return nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON, nn::Result::DESCRIPTION_OUT_OF_MEMORY); } - common::HeapManager heap(bodySize); + common::HeapManager heap(bodySize + 1); void* buf = heap.GetAddr(); - if(!comm.GetBody(reinterpret_cast(buf), bodySize)) + if(!comm.GetBody(reinterpret_cast(buf), bodySize + 1)) { return comm.GetLastResult(); } + // NULL終端する + reinterpret_cast(buf)[bodySize] = '\0'; if(!comm.Finalize()) { diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp index 256f232..dbf2617 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/BgsCommunicator/test_BgsCommunicator.cpp @@ -126,11 +126,18 @@ void BgsCommunicatorTest::Exec() comm.Execute(xml.GetData().c_str(), xml.GetData().size()); size_t bufSize; comm.GetBodySize(&bufSize); - common::HeapManager heap(bufSize); + common::HeapManager heap(bufSize + 1); void* buf = heap.GetAddr(); - comm.GetBody(reinterpret_cast(buf), bufSize); + comm.GetBody(reinterpret_cast(buf), bufSize + 1); comm.Finalize(); + // NULL終端する + reinterpret_cast(buf)[bufSize] = '\0'; + + // 変換前 + std::string before(reinterpret_cast(buf)); + PutString(before); + // simpleXMLに変換します ConsoleRestore::SimpleXmlPreprocessor pp; std::string xmlData(reinterpret_cast(buf));