Add typecast to prevent overflow of arithmatic results 74/283074/2 accepted/tizen/unified/20221103.165758
authorjiyong.min <jiyong.min@samsung.com>
Tue, 18 Oct 2022 00:51:44 +0000 (09:51 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Wed, 26 Oct 2022 06:39:59 +0000 (15:39 +0900)
Change-Id: I228f668c15a1bfecd4538a72099f0224bc876640

packaging/capi-media-image-util.spec
src/image_util_encode.c
src/image_util_private.c

index a732564..50b25f2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-image-util
 Summary:    A Image Utility library in Tizen Native API
-Version:    0.4.2
+Version:    0.4.3
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ec17918..5cb30fb 100644 (file)
@@ -181,6 +181,7 @@ int image_util_encode_set_resolution(image_util_encode_h handle, unsigned long w
 
        image_util_retvm_if(!_handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
        image_util_retvm_if((width == 0 || height == 0), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid resolution w : [%lu] h : [%lu]", width, height);
+       image_util_retvm_if((width >= UINT_MAX || height >= UINT_MAX), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid resolution w : [%lu] h : [%lu]", width, height);
 
        /* multi-src for a-gif */
        if (_handle->image_type == IMAGE_UTIL_GIF) {
index 8890937..53171a5 100644 (file)
@@ -462,7 +462,7 @@ static int __create_media_packet(media_format_h fmt, unsigned char *buffer, size
                        goto ERROR;
                }
 
-               plane_size = stride_width * stride_height;
+               plane_size = (size_t)(stride_width) * stride_height;
 
                ret = media_packet_get_video_plane_data_ptr(new_packet, i, &plane_ptr);
                if (ret != MEDIA_PACKET_ERROR_NONE) {
@@ -583,7 +583,7 @@ int _image_util_packet_to_image(media_packet_h packet, image_util_image_h *image
                        goto ERROR;
                }
 
-               plane_size = stride_width * stride_height;
+               plane_size = (size_t)(stride_width) * stride_height;
 
                ret = media_packet_get_video_plane_data_ptr(packet, i, &plane_ptr);
                if (ret != MEDIA_PACKET_ERROR_NONE) {