From: Suyeon Hwang Date: Fri, 13 Oct 2017 06:08:38 +0000 (+0900) Subject: Change api for transfering characters & Fix error check for fread X-Git-Tag: accepted/tizen/unified/20180228.071746~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89b7affb93d61a35145715753607787e4f7ccf8e;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Change api for transfering characters & Fix error check for fread Change-Id: I1b51f5703745bde141b01048dc1f736fc098a29d Signed-off-by: Suyeon Hwang --- diff --git a/client/vc.c b/client/vc.c index 78e5193..cc99912 100644 --- a/client/vc.c +++ b/client/vc.c @@ -104,15 +104,15 @@ static int __check_privilege(const char* uid, const char * privilege) char smack_label[1024] = {'\0',}; if (!p_cynara) { - return false; + return false; } fp = fopen(label_path, "r"); if (fp != NULL) { - if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0) - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to fread"); + if (sizeof(smack_label) != fread(smack_label, 1, sizeof(smack_label), fp)) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] fail to fread"); - fclose(fp); + fclose(fp); } pid_t pid = getpid(); @@ -120,10 +120,10 @@ static int __check_privilege(const char* uid, const char * privilege) int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); SLOG(LOG_DEBUG, TAG_VCC, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied"); if (session) - free(session); + free(session); if (ret != CYNARA_API_ACCESS_ALLOWED) - return false; + return false; return true; } diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index b60d778..1105002 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1434,7 +1434,7 @@ static void __vc_db_remove_space(char** string) //remove previous space if (' ' == temp[0]) - strncpy(temp, temp + 1, strlen(temp)); + memmove(temp, temp + 1, strlen(temp)); // remove next space if (' ' == temp[strlen(temp) - 1]) diff --git a/common/vc_command.c b/common/vc_command.c index 2d588e5..b1f0e68 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -97,15 +97,15 @@ static int __check_privilege(const char* uid, const char * privilege) char smack_label[1024] = {'\0',}; if (!p_cynara) { - return false; + return false; } fp = fopen(label_path, "r"); if (fp != NULL) { - if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0) - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] fail to fread"); + if (sizeof(smack_label) != fread(smack_label, 1, sizeof(smack_label), fp)) + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] fail to fread"); - fclose(fp); + fclose(fp); } pid_t pid = getpid(); @@ -113,10 +113,10 @@ static int __check_privilege(const char* uid, const char * privilege) int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); SLOG(LOG_DEBUG, TAG_VCCMD, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied"); if (session) - free(session); + free(session); if (ret != CYNARA_API_ACCESS_ALLOWED) - return false; + return false; return true; }