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));