Replace open() to access() to check permission 43/197343/1
authorjiyong.min <jiyong.min@samsung.com>
Fri, 11 Jan 2019 00:25:22 +0000 (09:25 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 11 Jan 2019 00:25:22 +0000 (09:25 +0900)
Change-Id: I62a57e30c2f00161046bf3cf9e446f0293aea4e7

src/thumbnail_util.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 3f8218f..08770d4
@@ -488,15 +488,13 @@ int __thumbnail_util_get_file_ext(const char *file_path, char *file_ext, int max
 int _thumbnail_util_check_media_type(const char *path, thumbnail_util_media_type_e *type)
 {
        int ret = 0;
-       int exist = 0;
        char mimetype[255] = {0,};
        const char *unsupported_type = "image/tiff";
        const char *supported_type = "application/vnd.ms-asf";
 
        // Check file is existed
        thumbnail_util_retv_if(path == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
-       exist = open(path, O_RDONLY);
-       if (exist < 0) {
+       if (access(path, R_OK) < 0) {
                if (errno == EACCES || errno == EPERM) {
                        thumbnail_util_error("Fail to open path: Permission Denied [%s]", path);
                        return  THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED;
@@ -505,7 +503,6 @@ int _thumbnail_util_check_media_type(const char *path, thumbnail_util_media_type
                        return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
                }
        }
-       close(exist);
 
        // Check media type
        ret = aul_get_mime_from_file(path, mimetype, sizeof(mimetype));