Change api for transfering characters & Fix error check for fread 12/155412/3
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 Oct 2017 06:08:38 +0000 (15:08 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 Oct 2017 06:36:03 +0000 (06:36 +0000)
Change-Id: I1b51f5703745bde141b01048dc1f736fc098a29d
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/vc.c
common/vc_cmd_db.c
common/vc_command.c

index 78e5193..cc99912 100644 (file)
@@ -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;
 }
 
index b60d778..1105002 100644 (file)
@@ -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])
index 2d588e5..b1f0e68 100644 (file)
@@ -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;
 }