Fix error check for fread 33/155433/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 Oct 2017 06:31:03 +0000 (15:31 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 13 Oct 2017 06:33:45 +0000 (15:33 +0900)
Change-Id: I010446098278d180cf8b546123bb9790d48395e9
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/stt.c

index a986912..2035dea 100644 (file)
@@ -100,15 +100,15 @@ static bool __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_STTC, "[ERROR] fail to fread");
+               if (sizeof(smack_label) != fread(smack_label, 1, sizeof(smack_label), fp))
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] fail to fread");
 
-           fclose(fp);
+               fclose(fp);
        }
 
        pid_t pid = getpid();
@@ -121,7 +121,7 @@ static bool __check_privilege(const char* uid, const char * privilege)
        }
 
        if (ret != CYNARA_API_ACCESS_ALLOWED)
-           return false;
+               return false;
        return true;
 }