memcmpを使うように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@113 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-03-11 08:31:52 +00:00
parent 165a692ddd
commit 425cd46d91

View File

@ -26,21 +26,6 @@
namespace common
{
bool Compare(const bit8* p0, const bit8* p1, size_t size)
{
s32 i;
bool result = true;
for (i = 0; i < size; ++i)
{
if (*(p0 + i) != *(p1 + i))
{
result = false;
}
}
return result;
} // Compare
nn::Result SdReaderWriter::Initialize()
{
nn::Result result;
@ -228,7 +213,7 @@ nn::Result SdReaderWriter::ReadBufWithCmac(const wchar_t* path, void* buf, size_
result = nn::crypto::CalculateAesCmacSw(cmac, sha256Hash, nn::crypto::Sha256Context::HASH_SIZE, common::cmacKey);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
if(!Compare(reinterpret_cast<bit8*>(buf) + *totalSize, cmac, sizeof(cmac)))
if(std::memcmp(reinterpret_cast<bit8*>(buf) + *totalSize, cmac, sizeof(cmac)) != 0)
{
// 無効なファイル
COMMON_LOGGER("Verification Failed\n");