From: jiyong.min Date: Thu, 10 Jan 2019 08:42:33 +0000 (+0900) Subject: Add to check the file permission before set the path X-Git-Tag: submit/tizen/20190124.005947~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F197232%2F6;p=platform%2Fcore%2Fapi%2Fimage-util.git Add to check the file permission before set the path Change-Id: I53a57e327e74520c30cc1b7054f52d12f5b11def --- diff --git a/src/image_util_decode.c b/src/image_util_decode.c index a1c1656..9d799ad 100755 --- a/src/image_util_decode.c +++ b/src/image_util_decode.c @@ -46,7 +46,15 @@ static int _image_util_decode_read_header(const char *path, unsigned char **buff image_util_retvm_if(buffer == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid buffer"); fp = fopen(path, "r"); - image_util_retvm_if(fp == NULL, IMAGE_UTIL_ERROR_NO_SUCH_FILE, "File open failed %s", path); + if (fp == NULL) { + if (errno == EACCES || errno == EPERM) { + image_util_error("Fail to open path: Permission Denied [%s]", path); + return IMAGE_UTIL_ERROR_PERMISSION_DENIED; + } else { + image_util_error("Fail to open path: Invalid Path [%s]", path); + return IMAGE_UTIL_ERROR_NO_SUCH_FILE; + } + } read_buffer = (void *)calloc(1, IMG_HEADER_LENGTH + 1); if (read_buffer == NULL) { diff --git a/src/image_util_encode.c b/src/image_util_encode.c old mode 100755 new mode 100644