From 75255308c43eaedbdcaf29be05a8453495af6a26 Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Thu, 8 Oct 2015 15:09:06 +0900 Subject: [PATCH] Fix bug : sometimes failed to get root CA [Problem] Sometimes failed to complete cert chain [Cause] getNameHash function return type is std::string. But searchByHash function get returned value and use it as .c_str() directly. So rvalue isn't saved properly and sometimes it goes to be empty. [Solution] Get returned std::string to proper variable(lvalue with std::string) [Verification] Try 50 times to install sample tpk and no error occured. Change-Id: Ic4b6e72c0f791546f04f7b37c6f2d1c9c40d1f8a Signed-off-by: Kyungwook Tak --- vcore/vcore/CertificateCollection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcore/vcore/CertificateCollection.cpp b/vcore/vcore/CertificateCollection.cpp index 89b190d..7223b4e 100644 --- a/vcore/vcore/CertificateCollection.cpp +++ b/vcore/vcore/CertificateCollection.cpp @@ -57,7 +57,7 @@ inline std::string toBinaryString(int data) CertificatePtr searchCertByHash(const std::string &dir, const CertificatePtr &certPtr) { try { - const char *hash = certPtr->getNameHash(Certificate::FIELD_ISSUER).c_str(); + std::string hash = certPtr->getNameHash(Certificate::FIELD_ISSUER); std::unique_ptr> dp(::opendir(dir.c_str()), ::closedir); if (dp.get() == NULL) { @@ -79,7 +79,7 @@ CertificatePtr searchCertByHash(const std::string &dir, const CertificatePtr &ce if (strlen(dirp->d_name) != 10) continue; - if (strncmp(dirp->d_name, hash, 8) != 0) + if (strncmp(dirp->d_name, hash.c_str(), 8) != 0) continue; LogDebug("Found hash matched file! : " << (dir + dirp->d_name)); -- 2.7.4