Add to check the return of fseek() 81/198681/2 tizen_5.5_dev accepted/tizen/unified/20190207.120252 submit/tizen/20190131.041045
authorjiyong.min <jiyong.min@samsung.com>
Mon, 28 Jan 2019 08:23:39 +0000 (17:23 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Mon, 28 Jan 2019 23:17:11 +0000 (08:17 +0900)
 - If fseek() is failed, -1 is returned and errno is set to indicate the errors.

Change-Id: Id5cc540e185d310d287c417160ca321f4322a5a4

bmp/test/mm_util_bmp_testsuite.c [changed mode: 0755->0644]
bmp/unittest/FileInterface.cpp
gif/unittest/FileInterface.cpp
imgp/test/mm_util_imgp_testsuite.c [changed mode: 0755->0644]
jpeg/test/mm_util_jpeg_testsuite.c [changed mode: 0755->0644]
jpeg/unittest/FileInterface.cpp
magick/mm_util_info.c
png/test/mm_util_png_testsuite.c [changed mode: 0755->0644]
png/unittest/FileInterface.cpp

old mode 100755 (executable)
new mode 100644 (file)
index 5a6ba41..7a062ee
@@ -82,7 +82,12 @@ static gboolean _read_file(char *path, void **data, size_t *length)
                return FALSE;
        }
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0) {
+               fprintf(stderr, "\t[BMP_testsuite] fseek failed \n");
+               fclose(fp);
+               return FALSE;
+       }
+
        len = ftell(fp);
        if (len < 0) {
                fprintf(stderr, "\t[BMP_testsuite] ftell failed \n");
index 8dbbdee..cf8c8bf 100644 (file)
@@ -43,7 +43,9 @@ void FileInterface::Open(const char *path)
 
        long size = 0;
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0)
+               return ;
+
        size = (size_t)ftell(fp);
        rewind(fp);
 
index 8dbbdee..cf8c8bf 100644 (file)
@@ -43,7 +43,9 @@ void FileInterface::Open(const char *path)
 
        long size = 0;
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0)
+               return ;
+
        size = (size_t)ftell(fp);
        rewind(fp);
 
old mode 100755 (executable)
new mode 100644 (file)
index 3f721ce..a67124e
@@ -49,7 +49,12 @@ static gboolean _read_file(char *path, void **data, size_t *length)
                return FALSE;
        }
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0) {
+               fprintf(stderr, "\t[JPEG_testsuite] fseek failed \n");
+               fclose(fp);
+               return FALSE;
+       }
+
        len = ftell(fp);
        if (len < 0) {
                fprintf(stderr, "\t[JPEG_testsuite] ftell failed \n");
old mode 100755 (executable)
new mode 100644 (file)
index 19496bd..5bdf8ca
@@ -85,7 +85,12 @@ static gboolean _read_file(char *path, void **data, size_t *length)
                return FALSE;
        }
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0) {
+               fprintf(stderr, "\t[JPEG_testsuite] fseek failed \n");
+               fclose(fp);
+               return FALSE;
+       }
+
        len = ftell(fp);
        if (len < 0) {
                fprintf(stderr, "\t[JPEG_testsuite] ftell failed \n");
index 8dbbdee..cf8c8bf 100644 (file)
@@ -43,7 +43,9 @@ void FileInterface::Open(const char *path)
 
        long size = 0;
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0)
+               return ;
+
        size = (size_t)ftell(fp);
        rewind(fp);
 
index af2d00a..8e63a22 100755 (executable)
@@ -49,8 +49,10 @@ void __ImgGetFileAttributes(const char *szPathName, unsigned long *pFileAttr)
 
        f = fopen(szPathName, "r");
        if (f != NULL) {
-               fseek(f, 0, SEEK_END);
-               *pFileAttr = ftell(f);
+               if (fseek(f, 0, SEEK_END) < 0)
+                       mm_util_stderror("fseek failed");
+               else
+                       *pFileAttr = ftell(f);
                fclose(f);
        }
 }
@@ -108,7 +110,7 @@ static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt,
                unsigned long long i = 4;
 
                if (fseek(hFile, block_length + 4, SEEK_CUR) < 0) {
-                       mm_util_error("fseek was failed");
+                       mm_util_stderror("fseek failed");
                        return MM_UTIL_ERROR_INVALID_OPERATION;
                }
 
@@ -147,7 +149,7 @@ static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt,
                                mm_util_sec_debug("new block length : %u", block_length);
 
                                if (fseek(hFile, block_length - JPG_BLOCK_SIZE_LENGTH, SEEK_CUR) < 0) {
-                                        mm_util_error("fseek was failed");
+                                        mm_util_stderror("fseek failed");
                                         return MM_UTIL_ERROR_INVALID_OPERATION;
                                }
                        }
@@ -261,7 +263,9 @@ int mm_util_extract_image_info(const char *path, mm_util_img_codec_type *type, u
 
        ret = _ImgGetImageInfo(hFile, file_size, file_ext, type, width, height);
 
-       fseek(hFile, 0, SEEK_SET);
+       if (fseek(hFile, 0, SEEK_SET) < 0)
+               mm_util_stderror("fseek failed");
+
        fclose(hFile);
 
        return ret;
old mode 100755 (executable)
new mode 100644 (file)
index 6d6512d..44851d7
@@ -83,7 +83,12 @@ static gboolean _read_file(char *path, void **data, size_t *length)
                return FALSE;
        }
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0) {
+               fprintf(stderr, "\t[PNG_testsuite] fseek failed \n");
+               fclose(fp);
+               return FALSE;
+       }
+
        len = ftell(fp);
        if (len < 0) {
                fprintf(stderr, "\t[PNG_testsuite] ftell failed \n");
index 8dbbdee..cf8c8bf 100644 (file)
@@ -43,7 +43,9 @@ void FileInterface::Open(const char *path)
 
        long size = 0;
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0)
+               return ;
+
        size = (size_t)ftell(fp);
        rewind(fp);