Check permission before setting destination path #2 71/176771/2 accepted/tizen/unified/20180503.080741 submit/tizen/20180503.003835
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 23 Apr 2018 09:53:15 +0000 (18:53 +0900)
committerseonah moon <seonah1.moon@samsung.com>
Mon, 23 Apr 2018 09:55:12 +0000 (09:55 +0000)
Add checking code a path whether default or not.

Change-Id: Ic1f5a4058e1b5d9de96bb36660f0f2256d309bbd

provider/download-provider-security.c

index 862d8a9..bf1590f 100644 (file)
@@ -126,6 +126,7 @@ static int _dp_check_dir_permission(dp_credential cred, const char *privilege)
 
 int dp_is_valid_dir(dp_credential cred, const char *dirpath)
 {
+       char default_storage[PATH_MAX + 1] = {0, };
        char media_storage[PATH_MAX + 1] = {0, };
        char external_storage[PATH_MAX + 1] = {0, };
        char apps_storage[PATH_MAX + 1] = {0, };
@@ -158,6 +159,16 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
 
        tzplatform_set_user(cred.uid);
 
+       // Check whether directory is default directory or not.
+       temp = tzplatform_getenv(TZ_USER_DOWNLOADS);
+       if (temp) {
+               snprintf(default_storage, PATH_MAX - 1, "%s/", temp);
+               if (strncmp(resolved_path, default_storage,
+                                       strlen(default_storage)) == 0)
+                               return DP_ERROR_NONE;
+               temp = NULL;
+       }
+
        // Check permission: media storage
        temp = tzplatform_getenv(TZ_USER_CONTENT);
        if (temp) {