From 5fecd9169f1562b51376e6d1955f854b7d6fe1d7 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Thu, 21 Apr 2016 16:22:43 +0900 Subject: [PATCH] Fixed invalid smack label for cynara check Change-Id: I2b4df144d3350aaf4aa58efed3c0928c2b179de4 Signed-off-by: kj7.sung --- location/manager/location-privacy.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/location/manager/location-privacy.c b/location/manager/location-privacy.c index ec3eede..d0a3fa9 100644 --- a/location/manager/location-privacy.c +++ b/location/manager/location-privacy.c @@ -41,7 +41,7 @@ int location_check_cynara(const char *privilege_name) FILE *fp = NULL; char uid[16]; char *session = NULL; - char smack_label[100] = "/proc/self/attr/current"; + char smack_label[100] = {0, }; if (cynara_initialize(&cynara, NULL) != CYNARA_API_SUCCESS) { @@ -52,8 +52,11 @@ int location_check_cynara(const char *privilege_name) fp = fopen("/proc/self/attr/current", "r"); if (fp != NULL) { - if (fread(smack_label, 1, sizeof(smack_label), fp) <= 0) { - LOCATION_LOGE("fread failed"); + int ch = 0; + int idx = 0; + while (EOF != (ch = fgetc(fp))) { + smack_label[idx] = ch; + idx++; } fclose(fp); } -- 2.7.4