app_shared_dir_add_readers() accepts NULL in 'app_list' not ""
authorJan Cybulski <j.cybulski@samsung.com>
Thu, 18 Apr 2013 13:43:35 +0000 (15:43 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 24 Apr 2013 13:47:47 +0000 (15:47 +0200)
    [Issue#] SSDWSSP-196
    [Feature/Bug] app_shared_dir_add_readers() does not accept NULL in a list of arguments
    [Problem] N/A
    [Cause] Unification to other API functions
    [Solution] check if there if a NULL in a list of readers. Threat it as an end of a list.
    [Verification] libprivilege-control-test --output=text

Change-Id: I13079b349b9cdfb1ca6a01924e4e0f563f1b7e0f

src/privilege-control.c

index 477a59b..23a0f94 100644 (file)
@@ -1323,13 +1323,16 @@ API int add_shared_dir_readers(const char* shared_label, const char** app_list)
        int ret = PC_ERR_INVALID_PARAM;
        int i;
        int fd = -1;
-       for (i = 0; *app_list[i]; i++) {
+
+       if (!smack_label_is_valid(shared_label))
+                               return PC_ERR_INVALID_PARAM;
+
+       for (i = 0; app_list[i] != NULL; i++) {
                char *smack_path = NULL;
                struct smack_accesses *smack = NULL;
 
-
-               if (!smack_label_is_valid(shared_label))
-                               return PC_ERR_INVALID_PARAM;
+               if (!smack_label_is_valid(app_list[i]))
+                                       return PC_ERR_INVALID_PARAM;
 
                ret = load_smack_from_file(
                                app_list[i], &smack, &fd, &smack_path);