From dfddbf974a5addc9e15655093b51e0679d2f415e Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Fri, 19 Apr 2013 14:23:14 +0900 Subject: [PATCH] fix prevent issue Change-Id: I3c764fb98021f1bff5eb6ef3e223a86842274e49 Signed-off-by: junsuk77.oh --- client/src/pkgmgr.c | 26 ++++++++++++++++---------- packaging/pkgmgr.spec | 3 +-- tool/pkg_cmd.c | 2 +- tool/pkg_info.c | 2 -- tool/pkgmgr-install.c | 10 ++++++++-- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 10c1dca..b4774b2 100755 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -141,10 +141,10 @@ static int __csc_process(const char *csc_path, char *result_path) retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path); file = fopen(result_path, "w"); - retvm_if(file == NULL, PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path); + tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path); count = iniparser_getint(csc, "csc packages:count", -1); - retvm_if(count == 0, PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path); + tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path); snprintf(buf, PKG_STRING_LEN_MAX, "[csc %d packages]\n", count); fwrite(buf, 1, strlen(buf), file); @@ -200,12 +200,14 @@ static int __csc_process(const char *csc_path, char *result_path) } fwrite(buf, 1, strlen(buf), file); +catch: iniparser_freedict(csc); - fflush(file); - fd = fileno(file); - fsync(fd); - fclose(file); - + if (file != NULL) { + fflush(file); + fd = fileno(file); + fsync(fd); + fclose(file); + } return ret; } @@ -1642,8 +1644,8 @@ API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, switch (service_type) { case PM_REQUEST_CSC: - retvm_if(custom_info == NULL, PKGMGR_R_EINVAL, "custom_info is NULL\n"); - retvm_if(data == NULL, PKGMGR_R_EINVAL, "data is NULL\n"); + tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n"); + tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n"); ret = __csc_process(custom_info, (char *)data); if (ret < 0) @@ -1664,7 +1666,11 @@ API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, break; } - return req_id; +catch: + if (req_key) + free(req_key); + + return ret; } diff --git a/packaging/pkgmgr.spec b/packaging/pkgmgr.spec index e03c5d6..ef64f5a 100755 --- a/packaging/pkgmgr.spec +++ b/packaging/pkgmgr.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce Name: pkgmgr Summary: Packager Manager client library package -Version: 0.2.77 +Version: 0.2.78 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -26,7 +26,6 @@ BuildRequires: pkgmgr-info-parser Packager Manager client library package for packaging Requires(post): ail -Requires(post): xkeyboard-config %package client Summary: Package Manager client library develpoment package diff --git a/tool/pkg_cmd.c b/tool/pkg_cmd.c index fee2a2e..fcb3d0a 100755 --- a/tool/pkg_cmd.c +++ b/tool/pkg_cmd.c @@ -252,7 +252,7 @@ static int __return_cb(int req_id, const char *pkg_type, ret_val = atoi(val); data.result = ret_val; - ret_result = strtok(val, delims); + strtok(val, delims); ret_result = strtok(NULL, delims); if (ret_result){ extra_str = strdup(ret_result); diff --git a/tool/pkg_info.c b/tool/pkg_info.c index 1237297..f10216e 100755 --- a/tool/pkg_info.c +++ b/tool/pkg_info.c @@ -210,8 +210,6 @@ static int __add_metadata_filter() key = __get_string_input_data(); printf("enter metadata - value\n"); value = __get_string_input_data(); - if(strlen(value) == 0) - value = NULL; printf("filter condition : key=[%s], value=[%s]\n", key, value); diff --git a/tool/pkgmgr-install.c b/tool/pkgmgr-install.c index 4d9dc6e..5ac2c44 100755 --- a/tool/pkgmgr-install.c +++ b/tool/pkgmgr-install.c @@ -116,6 +116,7 @@ int main(int argc, char **argv) char *mime_type; char *file_path; const char *extension; + int request_id = 0; if (__parse_argv(argc, argv, &mime_type, &file_path)) { fprintf(stderr, "Failed to parse argv!\n"); @@ -133,9 +134,14 @@ int main(int argc, char **argv) int pid = fork(); if (pid == 0) { pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST); - pkgmgr_client_install(pc, extension, NULL, file_path, NULL, + request_id = pkgmgr_client_install(pc, extension, NULL, file_path, NULL, PM_DEFAULT, NULL, NULL); - pkgmgr_client_free(pc); + if (request_id < 0) + fprintf(stderr, "pkgmgr_client_install fail!\n"); + + request_id = pkgmgr_client_free(pc); + if (request_id < 0) + fprintf(stderr, "pkgmgr_client_free fail\n"); exit(0); } -- 2.7.4