[info] Add error handling when jpeg has junk data in header 98/177098/2
authorJiyong Min <jiyong.min@samsung.com>
Wed, 25 Apr 2018 09:03:53 +0000 (18:03 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 25 Apr 2018 09:13:54 +0000 (18:13 +0900)
 - If jpeg header has junk data, block of header does not start 'FF'.
  It is neccessary to read next block till fine block.

Change-Id: Ic4e852bc6a2519b4f4175d5e2812ee3a8aa891cb

magick/mm_util_info.c
packaging/libmm-utility.spec

index 82db411..c47cc81 100755 (executable)
@@ -113,8 +113,10 @@ static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt,
                        mm_util_retvm_if((fileread < JPG_HEADER_TYPE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
 
                        if (header_type[0] != 0xFF) {
-                               mm_util_warn("Failed to get w / h from jpeg at index [%d]", i);
-                               break;
+                               mm_util_warn("Failed to get w / h from jpeg at index [%d] and go to next block.", i);
+                               /* add error handling when jpeg image has junk data in header */
+                               block_length = JPG_HEADER_TYPE_LENGTH;
+                               continue;
                        }
 
                        if (header_type[1] == 0xC0 || header_type[1] == 0xC2) {
@@ -126,7 +128,7 @@ static int _ImgGetImageInfo(FILE *hFile, unsigned long fileSize, char *fileExt,
                                *pHeight = image_size[3] * 256 + image_size[4];
                                break;
                        } else {
-                               i += 2;
+                               i += JPG_HEADER_TYPE_LENGTH;
                                memset(block_size, 0, JPG_BLOCK_SIZE_LENGTH);
                                fileread = fread(block_size, sizeof(char), JPG_BLOCK_SIZE_LENGTH, hFile);
                                mm_util_retvm_if((fileread < JPG_BLOCK_SIZE_LENGTH), ret, "IMG_CODEC_UNKNOWN_TYPE in JPEG");
index 8e7389b..855dfdf 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.1.21
+Version:    0.1.22
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0