From 5cdbe4eae9b8ee0ba031895378b4afc8ab4dd4df Mon Sep 17 00:00:00 2001 From: "jc815.lee" Date: Mon, 27 May 2013 15:15:35 +0900 Subject: fix label length bug when using NULL gtoup id [model] GT-I8800 [binary_type] Platform [customer] OPEN [issue#] N/A [problem] If process smack label shorter than default, label is going to wrong [cause] didn't clean char array [solution] clean array [team] Framework [request] N/A [horizontal_expansion] Change-Id: I7e698b1ef06edef2f6970f8632f9a6b43d1b046b Signed-off-by: jc815.lee --- server/src/ss_server_main.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/server/src/ss_server_main.c b/server/src/ss_server_main.c index 69fdc0d..b762e65 100755 --- a/server/src/ss_server_main.c +++ b/server/src/ss_server_main.c @@ -225,21 +225,22 @@ int check_privilege_by_sockfd(int sockfd, const char* object, const char* access { int ret = -1; // if success, return 0 const char* private_group_id = "NOTUSED"; + char* default_smack_label = NULL; + const char* group_id = object; if(!IsSmackEnabled()) { return 0; } - if(!strncmp(object,"NOTUSED", strlen(private_group_id))) + if(!strncmp(group_id, private_group_id, strlen(private_group_id))) { - SLOGD("requested default group_id :%s. get smack label", object); - char* client_process_smack_label = security_server_get_smacklabel_sockfd(sockfd); - if(client_process_smack_label) + SLOGD("requested default group_id. get smack label"); + default_smack_label = security_server_get_smacklabel_sockfd(sockfd); + if(default_smack_label) { - SLOGD("defined smack label : %s", client_process_smack_label); - strncpy(object, client_process_smack_label, strlen(client_process_smack_label)); - free(client_process_smack_label); + SLOGD("defined smack label : %s", default_smack_label); + group_id = default_smack_label; } else { @@ -248,8 +249,13 @@ int check_privilege_by_sockfd(int sockfd, const char* object, const char* access } } - SLOGD("object : %s, access_rights : %s", object, access_rights); - ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights); + SLOGD("object : %s, access_rights : %s", group_id, access_rights); + ret = security_server_check_privilege_by_sockfd(sockfd, group_id, access_rights); + + if(default_smack_label) + { + free(default_smack_label); + } return ret; } -- cgit v1.2.3