[nx] Fix bug in ContentMetaBinary

This commit is contained in:
jakcron 2018-06-29 14:59:48 +08:00
parent 1e08495f5d
commit 38b93cb317

View file

@ -116,12 +116,14 @@ void nx::ContentMetaBinary::fromBytes(const byte_t* data, size_t len)
if (hdr->content_count.get() > 0) if (hdr->content_count.get() > 0)
{ {
const sContentInfo* info = (const sContentInfo*)(data + getContentInfoOffset(hdr->exhdr_size.get())); const sContentInfo* info = (const sContentInfo*)(data + getContentInfoOffset(hdr->exhdr_size.get()));
ContentInfo cinfo;
for (size_t i = 0; i < hdr->content_count.get(); i++) for (size_t i = 0; i < hdr->content_count.get(); i++)
{ {
mContentInfo[i].hash = info[i].content_hash; cinfo.hash = info[i].content_hash;
memcpy(mContentInfo[i].nca_id, info[i].content_id, cnmt::kContentIdLen); memcpy(cinfo.nca_id, info[i].content_id, cnmt::kContentIdLen);
mContentInfo[i].size = (uint64_t)(info[i].size_lower.get()) | (uint64_t)(info[i].size_higher.get()) << 32; cinfo.size = (uint64_t)(info[i].size_lower.get()) | (uint64_t)(info[i].size_higher.get()) << 32;
mContentInfo[i].type = (cnmt::ContentType)info[i].content_type; cinfo.type = (cnmt::ContentType)info[i].content_type;
mContentInfo.addElement(cinfo);
} }
} }
@ -129,12 +131,14 @@ void nx::ContentMetaBinary::fromBytes(const byte_t* data, size_t len)
if (hdr->content_meta_count.get() > 0) if (hdr->content_meta_count.get() > 0)
{ {
const sContentMetaInfo* info = (const sContentMetaInfo*)(data + getContentMetaInfoOffset(hdr->exhdr_size.get(), hdr->content_count.get())); const sContentMetaInfo* info = (const sContentMetaInfo*)(data + getContentMetaInfoOffset(hdr->exhdr_size.get(), hdr->content_count.get()));
ContentMetaInfo cmeta;
for (size_t i = 0; i < hdr->content_meta_count.get(); i++) for (size_t i = 0; i < hdr->content_meta_count.get(); i++)
{ {
mContentMetaInfo[i].id = info[i].id.get(); cmeta.id = info[i].id.get();
mContentMetaInfo[i].version = info[i].version.get(); cmeta.version = info[i].version.get();
mContentMetaInfo[i].type = (cnmt::ContentMetaType)info[i].type; cmeta.type = (cnmt::ContentMetaType)info[i].type;
mContentMetaInfo[i].attributes = info[i].attributes; cmeta.attributes = info[i].attributes;
mContentMetaInfo.addElement(cmeta);
} }
} }
@ -147,7 +151,6 @@ void nx::ContentMetaBinary::fromBytes(const byte_t* data, size_t len)
// save digest // save digest
memcpy(mDigest.data, data + getDigestOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), exdata_size), cnmt::kDigestLen); memcpy(mDigest.data, data + getDigestOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), exdata_size), cnmt::kDigestLen);
} }
const fnd::Vec<byte_t>& nx::ContentMetaBinary::getBytes() const const fnd::Vec<byte_t>& nx::ContentMetaBinary::getBytes() const