snprintf(): use sizeof() for size factor 59/255359/1 accepted/tizen/6.0/unified/20210318.101101 submit/tizen_6.0/20210318.044137
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 17 Mar 2021 09:14:43 +0000 (18:14 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 17 Mar 2021 09:29:01 +0000 (18:29 +0900)
Change-Id: Iad73c5df5f72be0cf80fa1743f97bc806d179117

packaging/download-provider.spec
provider/download-provider-security.c

index d4daee4..5bbf7c3 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.2.2
+Version:    2.2.3
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 332080a..0b72bec 100644 (file)
@@ -146,7 +146,7 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
                return DP_ERROR_INVALID_DESTINATION;
        }
 
-       strncpy(resolved_path, res, PATH_MAX - 1);
+       strncpy(resolved_path, res, sizeof(resolved_path) - 1);
        free(res);
 
        end = strlen(resolved_path) - 1;
@@ -170,7 +170,7 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
        // Check whether directory is default directory or not.
        temp = tzplatform_getenv(TZ_USER_DOWNLOADS);
        if (temp) {
-               snprintf(default_storage, PATH_MAX - 1, "%s/", temp);
+               snprintf(default_storage, sizeof(default_storage) - 1, "%s/", temp);
                if (strncmp(resolved_path, default_storage,
                                        strlen(default_storage)) == 0)
                                return DP_ERROR_NONE;
@@ -180,7 +180,7 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
        // Check permission: media storage
        temp = tzplatform_getenv(TZ_USER_CONTENT);
        if (temp) {
-               snprintf(media_storage, PATH_MAX - 1, "%s/", temp);
+               snprintf(media_storage, sizeof(media_storage) - 1, "%s/", temp);
                if (strncmp(resolved_path, media_storage,
                                        strlen(media_storage)) == 0) {
                        if (_dp_check_dir_permission(cred, MEDIA_STORAGE_PRIVILEGE) < 0) {
@@ -196,7 +196,7 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
        // Check permission: external storage
        temp = tzplatform_getenv(TZ_SYS_STORAGE);
        if (temp) {
-               snprintf(external_storage, PATH_MAX - 1, "%s/", temp);
+               snprintf(external_storage, sizeof(external_storage) - 1, "%s/", temp);
                if (strncmp(resolved_path, external_storage,
                                        strlen(external_storage)) == 0) {
                        if (_dp_check_dir_permission(cred, EXTERNAL_STORAGE_PRIVILEGE) < 0) {
@@ -212,10 +212,10 @@ int dp_is_valid_dir(dp_credential cred, const char *dirpath)
        // Check permission: private storage
        if (strncmp(resolved_path, LEGACY_USER_APP, strlen(LEGACY_USER_APP)) == 0) {
                // Some applications use a legacy app path.
-               snprintf(apps_storage, PATH_MAX - 1, "%s", LEGACY_USER_APP);
+               snprintf(apps_storage, sizeof(apps_storage) - 1, "%s", LEGACY_USER_APP);
        } else {
                temp = tzplatform_getenv(TZ_USER_APP);
-               snprintf(apps_storage, PATH_MAX - 1, "%s/", temp);
+               snprintf(apps_storage, sizeof(apps_storage) - 1, "%s/", temp);
                temp = NULL;
        }