Fix coverity issue (INTEGER_OVERFLOW) 17/307117/3
authorJiyong <jiyong.min@samsung.com>
Tue, 5 Mar 2024 05:36:55 +0000 (14:36 +0900)
committerJiyong <jiyong.min@samsung.com>
Tue, 5 Mar 2024 06:03:47 +0000 (15:03 +0900)
Change-Id: I867ae6ae067cfa09689b088de935b887b5459811

packaging/libmm-fileinfo.spec
utils/mm_file_util_tag.c

index 94c7c2c..806c3c8 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    1.0.25
+Version:    1.0.26
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index b9898f7..42844c6 100644 (file)
@@ -1961,10 +1961,10 @@ int ParseSpatialVideoMetadataFromXMLString(const char *xmlStr, MMFileFormatConte
 int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
 {
        MMFileIOHandle *fp = NULL;
-       int probe_size = 10000;
+       long long probe_size = 10000;
        unsigned char *buffer = NULL;
        int ret = 0;
-       int i;
+       long long i;
        long long file_size = 0;
 
        MMFILE_WEBM_PROJ_V2_BOX v2box = { 0, };
@@ -2007,7 +2007,7 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
        for (i = 0; i + 3 < probe_size; ++i) {
                if (*(unsigned int *)(buffer + i) == FOURCC('e', 'q', 'u', 'i') ||
                                *(unsigned int *)(buffer + i) == FOURCC('c', 'b', 'm', 'p')) {
-                       debug_msg(DEBUG, "projection data found at offset %d bytes", i);
+                       debug_msg(DEBUG, "projection data found at offset %lld bytes", i);
                        break;
                }
        }
@@ -2018,7 +2018,7 @@ int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext)
                goto exit;
        }
 
-       if ((i - (int)sizeof(MMFILE_WEBM_PROJ_V2_BOX)) < 0) {
+       if ((i - sizeof(MMFILE_WEBM_PROJ_V2_BOX)) < 0) {
                debug_error(DEBUG, "error: invalid supposed projection info location");
                ret = MMFILE_UTIL_FAIL;
                goto exit;
@@ -2127,6 +2127,10 @@ int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
        }
 
        basic_header.start_offset = mmfile_tell(fp);
+       if (basic_header.start_offset < 0) {
+               debug_error(DEBUG, "error: mmfile_tell");
+               goto exit;
+       }
 
        if (g_junk_counter_limit == 0)
                g_junk_counter_limit = mmfile_get_int_from_ini(MMFILE_INI_JUNKCNTLIMIT, MMFILE_DEFAULT_JUNKCNTLIMIT);