Fix coverity defects 82/173582/1 submit/tizen/20180403.094824
authorDongsun Lee <ds73.lee@samsung.com>
Thu, 22 Mar 2018 09:53:24 +0000 (18:53 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Thu, 22 Mar 2018 09:53:24 +0000 (18:53 +0900)
- 110857 Uninitialized scalar variable
- 106335 Uninitialized scalar variable
- 107729 Resource leak
- 105668 Unchecked return value from library
- 106114 Logically dead code
- 108585 Big parameter passed by value

Change-Id: I4081c2b0fe688bf8af6e0102a9dba690a84e23f7
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
src/dpl/core/src/assert.cpp
src/server/src/cert-server-logic.c
src/vcore/Certificate.cpp
src/vcore/SignatureValidator.cpp
src/vcore/pkcs12.cpp

index 16251d5..6e2af20 100644 (file)
@@ -42,7 +42,7 @@ void AssertProc(const char *condition,
                LogError("### Line: " << line);
                LogError("### Function: " << function);
                LogError("########################################################################");
-       } catch (Exception) {
+       } catch (Exception &) {
                // Just ignore possible double errors
        }
 
index 8fff0ee..28dba6d 100644 (file)
@@ -1149,11 +1149,6 @@ int deleteCertificateFromStore(CertStoreType storeType, const char *gname)
                query = NULL;
        }
 
-       if (stmt) {
-               sqlite3_finalize(stmt);
-               stmt = NULL;
-       }
-
        CertStoreType other = ALL_STORE & ~SYSTEM_STORE & ~storeType;
        CertStoreType current;
        int gname_exist = 0;
index 875adca..36e021b 100644 (file)
@@ -100,11 +100,12 @@ Certificate::Certificate(const std::string &data,
                                          "Internal Openssl error in d2i_X509 function.");
 }
 
-static off_t getFileSize(const std::string &location)
+static int getFileSize(const std::string &location, off_t &size)
 {
        struct stat status;
-       stat(location.c_str(), &status);
-       return status.st_size;
+       int ret = stat(location.c_str(), &status);
+       size = status.st_size;
+       return ret;
 }
 
 CertificatePtr Certificate::createFromFile(const std::string &location)
@@ -130,8 +131,10 @@ CertificatePtr Certificate::createFromFile(const std::string &location)
                return CertificatePtr(new Certificate(x509));
        }
 
-       off_t filesize = getFileSize(location);
-
+       off_t filesize = 0;
+       if(getFileSize(location, filesize) != 0)
+               VcoreThrowMsg(Certificate::Exception::WrongParamError,
+                                       "Fail to get file size. : " << location);
        if (filesize == 0)
                VcoreThrowMsg(Certificate::Exception::WrongParamError,
                                          "File content is empty : " << location);
index 87c3672..68ebe0c 100644 (file)
@@ -96,7 +96,7 @@ VCerr SignatureValidator::Impl::checkAll(bool checkOcsp,
        if (m_fileInfoSet.size() < 2)
                return E_SIG_UNKNOWN; // TODO(sangwan.kwon) Add error code (INVALID SIZE)
 
-       VCerr result;
+       VCerr result = E_SIG_UNKNOWN;
        for (const auto &sig : m_fileInfoSet) {
                m_fileInfo = sig;
                m_disregarded = false;
@@ -123,7 +123,7 @@ VCerr SignatureValidator::Impl::checkListAll(bool checkOcsp,
        if (m_fileInfoSet.size() < 2)
                return E_SIG_UNKNOWN; // TODO(sangwan.kwon) Add error code (INVALID SIZE)
 
-       VCerr result;
+       VCerr result = E_SIG_UNKNOWN;
        for (const auto &sig : m_fileInfoSet) {
                m_fileInfo = sig;
                m_disregarded = false;
index 5734004..51d9d77 100644 (file)
@@ -665,6 +665,7 @@ void rollbackStore(CertStoreType storeTypes, const std::string &endCertName)
                        vcore_client_delete_certificate_from_store(storeType, certChainName[i]);
                        free(certChainName[i]);
                }
+               free(certChainName);
 
                vcore_client_delete_certificate_from_store(storeType, endCertName.c_str());
        }