Fixed crash during saving certificate.
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 17 Apr 2013 05:51:43 +0000 (14:51 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 17 Apr 2013 05:51:43 +0000 (14:51 +0900)
[Issue#] N/A
[Problem] fail during saving certificate.
[Cause] there is bug at set certificate.
[Solution] null check during set certificate.
[SCMRequest] N/A

Change-Id: I06e7dbb47dd7040ba416114ba3e2e1a3edc9668a

src/jobs/widget_install/task_certificates.cpp

index 04247fa..a6693bc 100644 (file)
@@ -91,6 +91,7 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
         LogDebug("Insert certinfo to pkgmgr structure");
 
         ValidationCore::CertificateCollection chain;
+
         if (false == chain.load(*it)) {
             LogError("Chain is broken");
             ThrowMsg(Exceptions::SetCertificateInfoFailed,
@@ -108,11 +109,17 @@ void TaskCertificates::SetCertiInfo(CertificateSource source)
             pkgmgr_instcert_type instCertType;
 
             if (source == SIGNATURE_DISTRIBUTOR) {
-                std::string
-                Name(DPL::ToUTF8String(*(*certIt)->getOrganizationName()));
-                size_t found = Name.find("Tizen");
+                bool distributor1 = false;
+                if (!(*certIt)->getCommonName().IsNull()) {
+                    std::string
+                        Name(DPL::ToUTF8String(*(*certIt)->getCommonName()));
+                    std::string tizenStr("Tizen");
+                    if (0 == Name.compare(0, tizenStr.length(), tizenStr)) {
+                        distributor1 = true;
+                    }
+                }
 
-                if (found != std::string::npos) {
+                if (distributor1) {
                     LogDebug("Set SIGNATURE_DISTRIBUTOR");
                     if ((*certIt)->isRootCert()) {
                         instCertType = PM_SET_DISTRIBUTOR_ROOT_CERT;