From: jiyong.min Date: Fri, 11 Jan 2019 00:25:22 +0000 (+0900) Subject: Replace open() to access() to check permission X-Git-Tag: submit/tizen/20190311.013617~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f50df4268de988b20344649cc9d9b442ea337a2d;p=platform%2Fcore%2Fapi%2Fthumbnail-util.git Replace open() to access() to check permission Change-Id: I62a57e30c2f00161046bf3cf9e446f0293aea4e7 --- diff --git a/src/thumbnail_util.c b/src/thumbnail_util.c old mode 100755 new mode 100644 index 3f8218f..08770d4 --- a/src/thumbnail_util.c +++ b/src/thumbnail_util.c @@ -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));