fix static analysis defects 29/76429/1 accepted/tizen/common/20160624.133946 accepted/tizen/ivi/20160624.064725 accepted/tizen/mobile/20160624.064629 accepted/tizen/tv/20160624.064545 accepted/tizen/wearable/20160624.064746 submit/tizen/20160624.023426
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 24 Jun 2016 02:14:32 +0000 (11:14 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 24 Jun 2016 02:14:32 +0000 (11:14 +0900)
Change-Id: I57f42828e938011ecdf916cf755099614b43e6fb
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
plugin/app2sd/src/app2sd_interface.c
plugin/app2sd/src/app2sd_internals_registry.c
src/app2ext_interface.c
test/src/test_app2ext.c

index 29d69bd..6f2f53d 100644 (file)
@@ -1044,6 +1044,7 @@ int app2sd_enable_full_pkg(void)
        ret = _app2sd_initialize_db();
        if (ret) {
                _E("app2sd db initialize failed");
+               closedir(dir);
                return APP2EXT_ERROR_SQLITE_REGISTRY;
        }
 
@@ -1106,6 +1107,7 @@ int app2sd_disable_full_pkg(void)
        ret = _app2sd_initialize_db();
        if (ret) {
                _E("app2sd db initialize failed");
+               closedir(dir);
                return APP2EXT_ERROR_SQLITE_REGISTRY;
        }
 
index 7d7da9b..14e1c02 100644 (file)
@@ -90,6 +90,10 @@ static int _app2sd_check_existing_info(const char *pkgid, uid_t uid)
 
        query = sqlite3_mprintf("select count(*) from app2sd_info " \
                "where pkgid=%Q and uid=%d", pkgid, uid);
+       if (query == NULL) {
+               _E("failed to make a query");
+               return -1;
+       }
 
        ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
        if (ret != SQLITE_OK) {
@@ -175,6 +179,10 @@ int _app2sd_get_info_from_db(const char *filename, char **pkgid, uid_t *uid)
        _D("filename(%s)", filename);
        query = sqlite3_mprintf("select * from app2sd_info " \
                "where filename=%Q", filename);
+       if (query == NULL) {
+               _E("failed to make a query");
+               return APP2EXT_ERROR_SQLITE_REGISTRY;
+       }
 
        ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
        if (ret != SQLITE_OK) {
@@ -237,6 +245,10 @@ char *_app2sd_get_password_from_db(const char *pkgid, uid_t uid)
 
        query = sqlite3_mprintf("select * from app2sd_info " \
                "where pkgid=%Q and uid=%d", pkgid, uid);
+       if (query == NULL) {
+               _E("failed to make a query");
+               return NULL;
+       }
 
        ret = sqlite3_prepare_v2(app2sd_db, query, strlen(query), &stmt, NULL);
        if (ret != SQLITE_OK) {
index f8f5014..e16289a 100644 (file)
@@ -239,7 +239,7 @@ int app2ext_usr_disable_external_pkg(const char *pkgid, uid_t uid)
        char *encoded_id = NULL;
 
        /* validate the function parameter received */
-       if (pkgid == NULL || uid < 0) {
+       if (pkgid == NULL) {
                _E("invalid func parameters");
                return -1;
        }
@@ -331,7 +331,7 @@ int app2ext_usr_force_clean_pkg(const char *pkgid, uid_t uid)
        app2ext_handle *handle = NULL;
 
        /* validate the function parameter received */
-       if (pkgid == NULL || uid < 0) {
+       if (pkgid == NULL) {
                _E("invalid func parameters");
                return -1;
        }
index b587cf5..265ebf5 100644 (file)
@@ -234,12 +234,16 @@ FINISH_OFF:
 
 static int get_unzip_size(const char *item, unsigned long long *size)
 {
+       int ret = 0;
+       unzFile uzf = NULL;
+       char *filename = NULL;
+       unz_file_info fileInfo = { 0 };
+
        if (!item || !size) {
                printf("get size : invalid argument\n");
                return -1;
        }
-       int ret = 0;
-       unzFile uzf = unzOpen64(item);
+       uzf = unzOpen64(item);
        if (uzf == NULL) {
                printf("get size : failed to open item : [%s]\n", item);
                *size = 0;
@@ -261,14 +265,15 @@ static int get_unzip_size(const char *item, unsigned long long *size)
                                        return -1;
                                }
 
-                               unz_file_info fileInfo = { 0 };
-                               char *filename = (char *)calloc(1, 4096);
+                               filename = (char *)calloc(1, 4096);
                                ret = unzGetCurrentFileInfo(uzf, &fileInfo, filename, (4096 - 1), NULL, 0, NULL, 0);
                                *size = (unsigned long long)fileInfo.uncompressed_size + *size;
                                if (ret != UNZ_OK) {
                                        printf("get size : error get current file info\n");
                                        unzCloseCurrentFile(uzf);
                                        *size = 0;
+                                       free(filename);
+                                       filename = NULL;
                                        break;
                                }
 
@@ -460,7 +465,7 @@ static int app_move()
                ret = handle->interface.client_move(TEST_PKGNAME,
                        dir_list, APP2EXT_MOVE_TO_PHONE);
                print_error_code(__func__, ret);
-               ret = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
+               ret_check = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
                if (ret_check == APP2EXT_INTERNAL_MEM)
                        printf("pkg %s is moved to internal memory\n", TEST_PKGNAME);
        } else if (ret == APP2EXT_INTERNAL_MEM) {
@@ -469,7 +474,7 @@ static int app_move()
                ret = handle->interface.client_move(TEST_PKGNAME,
                        dir_list, APP2EXT_MOVE_TO_EXT);
                print_error_code(__func__, ret);
-               ret = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
+               ret_check = app2ext_usr_get_app_location(TEST_PKGNAME, getuid());
                if (ret_check == APP2EXT_SD_CARD)
                        printf("pkg %s is moved to sd card\n", TEST_PKGNAME);
        }  else {