Add null check routine for private_sharing 75/139175/3
authorMyungki Lee <mk5004.lee@samsung.com>
Mon, 17 Jul 2017 23:25:00 +0000 (08:25 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Tue, 18 Jul 2017 00:59:40 +0000 (09:59 +0900)
- last_index_of()
  is_private_file()

Change-Id: I700eb61f72f401eed80cf7f689cd1963708afd13
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
src/notification_shared_file.c

index 6c66f76e502650228e6c781893937720d7c0ff8a..1e04b4af927217f9f417f020650b408db4e147fa 100755 (executable)
@@ -125,8 +125,14 @@ static char *__get_data_path_by_pkg_id(const char *pkg_id,
 static const char *__last_index_of(const char *path, const char *search)
 {
        int i;
-       int search_len = strlen(search);
-       const char *index = path + strlen(path) - search_len;
+       int search_len;
+       const char *index;
+
+       if (path == NULL || search == NULL)
+               return NULL;
+
+       search_len = strlen(search);
+       index = path + strlen(path) - search_len;
 
        while (index >= path) {
                for (i = 0; i < search_len; i++)
@@ -147,6 +153,9 @@ static bool __is_private_file(const char *smack_label, const char *pkg_id)
        const char *smack_index;
        bool ret = false;
 
+       if (smack_label == NULL || pkg_id == NULL)
+               return ret;
+
        smack_index = __last_index_of(smack_label, pkg_id);
        if (smack_index != NULL && (strlen(smack_index) == strlen(pkg_id)))
                ret = true;