Fix not NULL terminated string 41/172241/4 accepted/tizen/unified/20180323.062052 submit/tizen/20180322.062955
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 13 Mar 2018 04:37:45 +0000 (13:37 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Fri, 16 Mar 2018 04:40:28 +0000 (13:40 +0900)
CID-106324

Change-Id: Ia12e2f88c48e1959fc825cb9b1dc64256bb87bad

src/http_common.c

index d749371..5751b6d 100644 (file)
@@ -50,7 +50,7 @@ bool _http_check_permission(http_privilege_e _privilege)
        FILE *fd;
 
        int ret;
-       char smack_label[SMACK_LABEL_LEN + 1];
+       char smack_label[SMACK_LABEL_LEN + 1] = {0, };
        char uid[10];
        char *client_session = "";
        char *privilege = NULL;
@@ -70,12 +70,14 @@ bool _http_check_permission(http_privilege_e _privilege)
                ERR("Failed to open /proc/self/attr/current\n");
                return false;
        }
-       ret = fread(smack_label, sizeof(smack_label), 1, fd);
-       fclose(fd);
-       if (ret < 0) {
+       ret = fread(smack_label, SMACK_LABEL_LEN, 1, fd);
+
+       if (ferror(fd)) {
                ERR("Failed to read /proc/self/attr/current\n");
+               fclose(fd);
                return false;
        }
+       fclose(fd);
 
        /* get uid */
        snprintf(uid, sizeof(uid), "%d", getuid());