Add missing log and pointer reset code 95/289495/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 9 Mar 2023 01:46:20 +0000 (10:46 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 9 Mar 2023 01:46:20 +0000 (10:46 +0900)
- Issue:
In some condition, the file pointer did not closed and made a memory
leakage.

- Solution:
In previous patch, a log for checking error status was missed. So, the
behavior of the code was not predictable. Thus, this patch restores the
log and also adds pointer reset code in order to prevent memory leakage.
Through this patch, the code will work as intented.

Change-Id: Id2524f579bd68e0f757910dbdf93e482dc402755
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/stte.c

index 59caa14..c2619c8 100755 (executable)
@@ -90,8 +90,10 @@ static bool is_privilege_allowed(const char* uid, const char * privilege)
        fp = fopen(label_path, "r");
        if (fp != NULL) {
                if (0 >= fread(smack_label, 1, sizeof(smack_label), fp))
+                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] fail to fread"); //LCOV_EXCL_LINE
 
                fclose(fp);
+               fp = NULL;
        }
 
        pid_t pid = getpid();