From 3a4259d2cc259978b4e2f7a809c12246c84e06f8 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sun, 29 Jul 2018 20:51:15 +0900 Subject: [PATCH] [es] Fixed a bug where string fields were not imported correctly. --- lib/libes/source/CertificateBody.cpp | 4 ++-- lib/libes/source/TicketBody_V2.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libes/source/CertificateBody.cpp b/lib/libes/source/CertificateBody.cpp index 11bec02..6219a21 100644 --- a/lib/libes/source/CertificateBody.cpp +++ b/lib/libes/source/CertificateBody.cpp @@ -129,10 +129,10 @@ void es::CertificateBody::fromBytes(const byte_t* src, size_t size) hdr = (const sCertificateHeader*)mRawBinary.data(); if (hdr->issuer[0] != 0) - mIssuer = std::string(hdr->issuer, cert::kIssuerSize); + mIssuer = std::string(hdr->issuer, _MIN(strlen(hdr->issuer), cert::kIssuerSize)); mPublicKeyType = (cert::PublicKeyType)hdr->key_type.get(); if (hdr->subject[0] != 0) - mSubject = std::string(hdr->subject, cert::kSubjectSize); + mSubject = std::string(hdr->subject, _MIN(strlen(hdr->subject), cert::kSubjectSize)); mCertId = hdr->cert_id.get(); // save public key diff --git a/lib/libes/source/TicketBody_V2.cpp b/lib/libes/source/TicketBody_V2.cpp index 8e19726..93816c7 100644 --- a/lib/libes/source/TicketBody_V2.cpp +++ b/lib/libes/source/TicketBody_V2.cpp @@ -112,7 +112,7 @@ void es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len) throw fnd::Exception(kModuleName, "Unsupported format version"); } - mIssuer.append(body->issuer, ticket::kIssuerSize); + mIssuer = std::string(body->issuer, _MIN(strlen(body->issuer), ticket::kIssuerSize)); memcpy(mEncTitleKey, body->enc_title_key, ticket::kEncTitleKeySize); mEncType = (ticket::TitleKeyEncType)body->title_key_enc_type; mTicketVersion = body->ticket_version.get();