From 66da058a334f6d24735e35f51d10205b8d869e27 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Thu, 10 Jan 2019 17:42:33 +0900 Subject: [PATCH] Add to check the file permission before set the path Change-Id: I53a57e327e74520c30cc1b7054f52d12f5b11def --- src/image_util_decode.c | 10 +++++++++- src/image_util_encode.c | 0 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/image_util_encode.c 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 -- 2.34.1