Add to check the file permission before set the path 32/197232/6
authorjiyong.min <jiyong.min@samsung.com>
Thu, 10 Jan 2019 08:42:33 +0000 (17:42 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 15 Jan 2019 07:24:06 +0000 (16:24 +0900)
Change-Id: I53a57e327e74520c30cc1b7054f52d12f5b11def

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

index a1c1656..9d799ad 100755 (executable)
@@ -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) {
old mode 100755 (executable)
new mode 100644 (file)