Fix null-terminated string issue after fread @download-provider-security.c 38/178038/1
authorTaesoo Jun <steve.jun@samsung.com>
Tue, 8 May 2018 00:49:17 +0000 (09:49 +0900)
committerTaesoo Jun <steve.jun@samsung.com>
Tue, 8 May 2018 00:49:17 +0000 (09:49 +0900)
Change-Id: I3dfad89e3f62c91648d7042bc7d8922325bfb957

provider/download-provider-security.c

index bf1590f..fa6c877 100644 (file)
@@ -106,7 +106,7 @@ static int _dp_check_dir_permission(dp_credential cred, const char *privilege)
                cynara_finish(p_cynara);
                return -1;
        }
-       ret = fread(client_smack, MAX_ARRAY_LEN, 1, fd);
+       ret = fread(client_smack, 1, MAX_ARRAY_LEN, fd);
        if (ferror(fd)) {
                TRACE_ERROR("Failed to read %s", client_smack_path);
                fclose(fd);
@@ -114,6 +114,7 @@ static int _dp_check_dir_permission(dp_credential cred, const char *privilege)
                return -1;
        }
        fclose(fd);
+       client_smack[ret] = '\0';
 
        snprintf(uid, sizeof(uid), "%d", cred.uid);