Fix potential buffer overflow 77/281877/1 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/hotfix/20221116.105434 accepted/tizen/unified/20220927.132306 tizen_7.0_m2_release
authorjiyong.min <jiyong.min@samsung.com>
Fri, 23 Sep 2022 00:49:13 +0000 (09:49 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 23 Sep 2022 00:49:13 +0000 (09:49 +0900)
- The 'jpeg_write_raw_data()' write 16 lines(heights) due to  DCT size.
- If the height is not a multiple of 16, use rounddown of a multiple of 16
  and remaining height.

Change-Id: Ic4a747817fb543e0d77ec7c764d4c8ad99e4411c

jpeg/mm_util_jpeg.c
packaging/libmm-utility.spec

index 35a4873..8b638d3 100644 (file)
@@ -229,15 +229,16 @@ static int __jpeg_encode_yuv(j_compress_ptr cinfo, unsigned int width, unsigned
        unsigned int i = 0, j = 0;
        void *large_rect = NULL;
        void *small_rect= NULL;
+       unsigned int rounddown_h = MM_UTIL_ROUND_DOWN_16(height);
 
-       if (cinfo->image_height - MM_UTIL_ROUND_DOWN_16(height)) {
+       if (cinfo->image_height != rounddown_h) {
                large_rect = g_malloc0(width);
                small_rect = g_malloc0(width);
 
                memset(large_rect, 0x10, width);
                memset(small_rect, 0x80, width);
 
-               for (j = 0; j < height; j += 16) {
+               for (j = 0; j < rounddown_h; j += 16) {
                        for (i = 0; i < 16; i++) {
                                y[i] = (JSAMPROW)decoded->data + width * (i + j);
                                if (i % 2 == 0) {
@@ -247,7 +248,7 @@ static int __jpeg_encode_yuv(j_compress_ptr cinfo, unsigned int width, unsigned
                        }
                        jpeg_write_raw_data(cinfo, data, 16);
                }
-               for (i = 0; i < cinfo->image_height - MM_UTIL_ROUND_DOWN_16(height); i++) {
+               for (i = 0; i < cinfo->image_height - rounddown_h; i++) {
                        y[i] = (JSAMPROW)decoded->data + width * (i + j);
                        if (i % 2 == 0) {
                                cb[i / 2] = (JSAMPROW)decoded->data + width * height + width / 2 * ((i + j) / 2);
index 62c5f8a..107c053 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.4.7
+Version:    0.4.8
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0