From 2e742ab4f03046a397821f9c64a6ef758410cb48 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 23 Sep 2018 11:39:27 +0800 Subject: [PATCH] [hac] Fixed bug with processing strings in NpdmBinary. --- lib/libhac/source/NpdmBinary.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/libhac/source/NpdmBinary.cpp b/lib/libhac/source/NpdmBinary.cpp index 716cc08..fe26c3a 100644 --- a/lib/libhac/source/NpdmBinary.cpp +++ b/lib/libhac/source/NpdmBinary.cpp @@ -132,16 +132,8 @@ void nn::hac::NpdmBinary::fromBytes(const byte_t* data, size_t len) mMainThreadCpuId = hdr.main_thread_cpu_id; mVersion = hdr.version.get(); mMainThreadStackSize = hdr.main_thread_stack_size.get(); - mName = std::string(hdr.name, npdm::kNameMaxLen); - if (mName[0] == '\0') - { - mName.clear(); - } - mProductCode = std::string(hdr.product_code, npdm::kProductCodeMaxLen); - if (mProductCode[0] == '\0') - { - mProductCode.clear(); - } + mName = std::string(hdr.name, _MIN(strlen(hdr.name), npdm::kNameMaxLen)); + mProductCode = std::string(hdr.product_code, _MIN(strlen(hdr.product_code), npdm::kProductCodeMaxLen)); // total size size_t total_size = _MAX(_MAX(hdr.acid.offset.get() + hdr.acid.size.get(), hdr.aci.offset.get() + hdr.aci.size.get()), sizeof(sNpdmHeader));