Fix prevent issue
authorDuyoung Jang <duyoung.jang@samsung.com>
Fri, 5 Apr 2013 10:24:16 +0000 (19:24 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Fri, 5 Apr 2013 10:24:16 +0000 (19:24 +0900)
Change-Id: Ib7fbb3da6e153dfadc24ada7f69bc1ed9acdb093
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Manager/ConfigurationManager.cpp
src/Manager/InstallerManager.cpp
src/Manager/SmackManager.cpp
src/Step/UninstallStep.cpp
src/Util/InstallerUtil.cpp
src/XmlHandler/Parser/ManifestLiveboxesParser.cpp

index fbd0659..9d10dc0 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130405.1]"
+#define OSP_INSTALLER_VERSION "version=[20130405.2]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 807f478..babcbb9 100755 (executable)
@@ -543,9 +543,10 @@ ConfigurationManager::MergeToSystemXmlFile(const String& systemXmlPath, const St
 
        File systemXml;
        r = systemXml.Construct(systemXmlPath, L"w");
-       TryReturn(!IsFailed(r), false, "systemXmlPath.Construct is failed");
+       TryReturn(!IsFailed(r), false, "systemXmlPath.Construct() is failed.");
 
-       systemXml.Write(pMergedBuf.get(), fileSize);
+       r = systemXml.Write(pMergedBuf.get(), fileSize);
+       TryReturn(!IsFailed(r), false, "systemXmlPath.Write() is failed.");
 
        AppLog("pMergedBuf.get()=0x%0x, length=%d", (unsigned int)pMergedBuf.get(), fileSize);
        InstallerUtil::DumpLogData(pMergedBuf.get(), fileSize);
index 9472e41..923c20f 100755 (executable)
@@ -545,6 +545,8 @@ CATCH:
 void
 InstallerManager::PrintResult(void)
 {
+       TryReturnVoid(__pContext, "__pContext is null.");
+
        int errorType = GetErrorType();
        InstallerOperation operation = __pContext->GetInstallerOperation();
 
@@ -553,13 +555,13 @@ InstallerManager::PrintResult(void)
        const char* pOperation = InstallerUtil::GetInstallerOperationString(operation);
 
        const wchar_t* pPackageId = L"Unknown";
-       if (__pContext && !__pContext->__packageId.IsEmpty())
+       if (!__pContext->__packageId.IsEmpty())
        {
                pPackageId = __pContext->__packageId.GetPointer();
        }
 
        const wchar_t* pMainAppName = L"Unknown";
-       if (__pContext && !__pContext->__mainAppName.IsEmpty())
+       if (!__pContext->__mainAppName.IsEmpty())
        {
                pMainAppName = __pContext->__mainAppName.GetPointer();
        }
@@ -746,10 +748,10 @@ InstallerManager::Request(const String& path, InstallerOperation operation, Inst
        packageId = pContext->__packageId;
 
 CATCH:
-       pInstallManager->SetErrorType(errorType);
-
        if (pInstallManager)
        {
+               pInstallManager->SetErrorType(errorType);
+
                if (!(option & INSTALLER_OPTION_NO_INPUT))
                {
                        pInstallManager->PrintResult();
index c0ff577..c69e476 100755 (executable)
@@ -198,7 +198,8 @@ SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPat
                std::unique_ptr<ByteBuffer> pHashValue(hash.GetHashN(*pEncodedData.get()));
                TryReturn(pHashValue, false, "pHashValue is null.");
 
-               StringUtil::EncodeToBase64String(*pHashValue, base64Value);
+               r = StringUtil::EncodeToBase64String(*pHashValue, base64Value);
+               TryReturn(r == E_SUCCESS, false, "EncodeToBase64String() is failed.");
 
                std::unique_ptr<char[]> pHashEncodedValue(_StringConverter::CopyToCharArrayN(base64Value));
                TryReturn(pHashEncodedValue, false, "pHashEncodedValue is null.");
@@ -384,7 +385,7 @@ SmackManager::Install(const char* pPackageId)
 
        app_install = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_install"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_install == null))
        {
                AppLog("Install(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -416,7 +417,7 @@ SmackManager::Uninstall(const char* pPackageId)
 
        app_uninstall = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_uninstall"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_uninstall == null))
        {
                AppLog("Uninstall(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -448,7 +449,7 @@ SmackManager::AddLabelDir(const char* pLabel, const char* pDirPath)
 
        app_label_dir = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_label_dir"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_label_dir == null))
        {
                AppLog("AddLabelDir(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -480,7 +481,7 @@ SmackManager::AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, co
 
        app_label_shared_dir = reinterpret_cast <int (*)(const char*, const char*, const char*)>(dlsym(pHandle, "app_label_shared_dir"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_label_shared_dir == null))
        {
                AppLog("AddLabelSharedDir(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -512,7 +513,7 @@ SmackManager::AddSharedDirReaders(const char* pSharedLabel, const char** ppAppLi
 
        add_shared_dir_readers = reinterpret_cast <int (*)(const char*, const char**)>(dlsym(pHandle, "add_shared_dir_readers"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (add_shared_dir_readers == null))
        {
                AppLog("AddSharedDirReaders(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -544,7 +545,7 @@ SmackManager::AddFriend(const char* pPackageId1, const char* pPackageId2)
 
        app_add_friend = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_add_friend"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_add_friend == null))
        {
                AppLog("AddFriend(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -576,7 +577,7 @@ SmackManager::EnablePermissions(const char* pPackageId, int appType, const char*
 
        app_enable_permissions = reinterpret_cast <int (*)(const char*, int, const char**, bool)>(dlsym(pHandle, "app_enable_permissions"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_enable_permissions == null))
        {
                AppLog("EnablePermissions(): dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
@@ -608,7 +609,7 @@ SmackManager::RevokePermissions(const char* pPackageId)
 
        app_revoke_permissions = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_revoke_permissions"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_revoke_permissions == null))
        {
                AppLog("RevokePermissions(): dlsym() failed. [%s][%s]", pPackageId, pErrorMsg);
                dlclose(pHandle);
@@ -640,7 +641,7 @@ SmackManager::AddPermissions(const char* pPackageId, const char** ppPermissions)
 
        app_add_permissions = reinterpret_cast <int (*)(const char*, const char**)>(dlsym(pHandle, "app_add_permissions"));
        pErrorMsg = dlerror();
-       if (pErrorMsg != null)
+       if ((pErrorMsg != null) || (app_add_permissions == null))
        {
                AppLog("AddPermissions(): dlsym() failed. [%s][%s]", pPackageId, pErrorMsg);
                dlclose(pHandle);
index 236ddec..0b7dc44 100755 (executable)
@@ -127,7 +127,9 @@ UninstallStep::OnStateGetPackageInfo(void)
        TryReturn(pPackageInfoImpl, INSTALLER_ERROR_OUT_OF_MEMORY, "pPackageInfoImpl is null.");
 
        AppLog("packageId = %ls", packageId.GetPointer());
-       pPackageInfoImpl->Construct(packageId);
+
+       result r = pPackageInfoImpl->Construct(packageId);
+       TryReturn(r == E_SUCCESS, INSTALLER_ERROR_INTERNAL_STATE, "pPackageInfoImpl->Construct(%ls) failed.", packageId.GetPointer());
 
        __pContext->__rootPath = pPackageInfoImpl->GetAppRootPath();
        if (__pContext->__rootPath.StartsWith(PATH_USR_APPS, 0) == true)
index 9cd9074..2f040d3 100755 (executable)
@@ -650,6 +650,7 @@ InstallerUtil::AppendLog(const char* pFunction, int lineNumber, bool fatal, cons
        r = file.Write(logs2, length+1);
        if (IsFailed(r))
        {
+               va_end(args);
                return false;
        }
        va_end(args);
@@ -711,6 +712,7 @@ InstallerUtil::PrintLog(const String& logFile)
 bool
 InstallerUtil::GetRdsList(const PackageId& packageId, IList* pDeletedList, IList* pAddedList, IList* pModifiedList)
 {
+       bool res = true;
        FILE* fp = null;
        char rdsFilePath[1024] = {0};
        char buffer[1024] = {0};
@@ -752,8 +754,8 @@ InstallerUtil::GetRdsList(const PackageId& packageId, IList* pDeletedList, IList
                }
 
                std::unique_ptr<String> pStr(new (std::nothrow) String(buffer));
-               TryReturn(pStr, false, "pStr is null.");
-               TryReturn(pStr->IsEmpty() == false, false, "pStr is empty.");
+               TryCatch(pStr, res = false, "pStr is null.");
+               TryCatch(pStr->IsEmpty() == false, res = false, "pStr is empty.");
 
                pStr->Trim();
                AppLog(".rds_delta: line(%03d)=[%ls]", line, pStr->GetPointer());
@@ -778,7 +780,9 @@ InstallerUtil::GetRdsList(const PackageId& packageId, IList* pDeletedList, IList
                memset(buffer, 0, sizeof(buffer));
        }
 
-       return true;
+CATCH:
+       fclose(fp);
+       return res;
 }
 
 const char*
index 9a1a930..519c3f6 100755 (executable)
@@ -220,8 +220,8 @@ ManifestLiveboxesParser::OnSizeValue(const char *pCharacters)
 
        AppLog("  <Size>%s</Size>", pCharacters);
 
-       String* pPreviewImage = new (std::nothrow) String();
-       TryReturn(pPreviewImage, false, "pPreviewImage is null");
+       std::unique_ptr< String > pPreviewImage(new (std::nothrow) String);
+       TryReturn(pPreviewImage, false, "pPreviewImage is null.");
 
        XmlAttribute* pAttr = pHandler->GetAttribute();
        if (pAttr)
@@ -250,7 +250,7 @@ ManifestLiveboxesParser::OnSizeValue(const char *pCharacters)
                }
        }
 
-       __pLiveboxData->AddSize(new (std::nothrow) String(pCharacters), pPreviewImage);
+       __pLiveboxData->AddSize(new (std::nothrow) String(pCharacters), pPreviewImage.release());
 
        return true;
 }