BGSとの通信結果はNULL終端してからXMLパースする必要がある

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
This commit is contained in:
N2614 2012-01-25 01:18:42 +00:00
parent ba07ffae01
commit 86a7f1526b
2 changed files with 14 additions and 5 deletions

View File

@ -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<u8*>(buf), bodySize))
if(!comm.GetBody(reinterpret_cast<u8*>(buf), bodySize + 1))
{
return comm.GetLastResult();
}
// NULL終端する
reinterpret_cast<u8*>(buf)[bodySize] = '\0';
if(!comm.Finalize())
{

View File

@ -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<u8*>(buf), bufSize);
comm.GetBody(reinterpret_cast<u8*>(buf), bufSize + 1);
comm.Finalize();
// NULL終端する
reinterpret_cast<u8*>(buf)[bufSize] = '\0';
// 変換前
std::string before(reinterpret_cast<char*>(buf));
PutString(before);
// simpleXMLに変換します
ConsoleRestore::SimpleXmlPreprocessor pp;
std::string xmlData(reinterpret_cast<char*>(buf));