diff options
author | jiyong.min <jiyong.min@samsung.com> | 2023-02-13 08:47:13 +0900 |
---|---|---|
committer | Jiyong Min <jiyong.min@samsung.com> | 2023-02-13 07:02:46 +0000 |
commit | c3adfb59ca994113c00209582f4d494a03ba1111 (patch) | |
tree | 5186bfb82cf81237c38b618d9b0543ce80dcf36b | |
parent | 53056d9ef79e1ff445a2967eefe4b2a4d6649f07 (diff) | |
download | libmedia-thumbnail-c3adfb59ca994113c00209582f4d494a03ba1111.tar.gz libmedia-thumbnail-c3adfb59ca994113c00209582f4d494a03ba1111.tar.bz2 libmedia-thumbnail-c3adfb59ca994113c00209582f4d494a03ba1111.zip |
Add image size limitation for specific devicesubmit/tizen_6.0/20230213.070825accepted/tizen/6.0/unified/20230213.125412
- This patch is for specific device, do not use it on other devices.
If necessary in the future, we will provide a hal-config that can be used on the others.
Change-Id: I6ee8f6fb8f03874d7c9cb31bd2b09e56af8a3a8f
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | src/media-thumbnail.c | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 68ab48d..01ad0f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,8 @@ ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") ADD_DEFINITIONS("-D_GNU_SOURCE") IF(WITH_DA_PROFILE) - # Enable reduced memory solution ADD_DEFINITIONS("-DUSE_MEMORY_USAGE_REDUCTION") + ADD_DEFINITIONS("-DENABLE_IMAGE_SIZE_LIMITATION") ENDIF(WITH_DA_PROFILE) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both") diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index a99482c..3432bed 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -511,6 +511,13 @@ static int __get_image_info(const char *path, unsigned int *width, unsigned int mm_util_img_codec_type image_type = 0; unsigned int image_w = 0; unsigned int image_h = 0; +#if defined(ENABLE_IMAGE_SIZE_LIMITATION) + const size_t image_size_limit[IMG_CODEC_UNKNOWN_TYPE] = { + [IMG_CODEC_JPEG] = (4096 * 4096), + [IMG_CODEC_PNG] = (3000 * 3000), + [IMG_CODEC_GIF] = (3000 * 3000), + }; +#endif thumb_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path"); thumb_retvm_if(!width, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid width"); @@ -520,7 +527,15 @@ static int __get_image_info(const char *path, unsigned int *width, unsigned int thumb_retvm_if(err != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INTERNAL, "Getting image info is failed err: %d", err); thumb_retvm_if(image_type == IMG_CODEC_UNKNOWN_TYPE, MS_MEDIA_ERR_UNSUPPORTED_CONTENT, "Unsupported image codec"); - +#if defined(ENABLE_IMAGE_SIZE_LIMITATION) + if ((image_type == IMG_CODEC_JPEG) || + (image_type == IMG_CODEC_PNG) || + (image_type == IMG_CODEC_GIF)) + if ((size_t)(image_w * image_h) > image_size_limit[image_type]) { + thumb_err("Unsupported image size [%u x %u] limit [%zu]", image_w, image_h, image_size_limit[image_type]); + return MS_MEDIA_ERR_UNSUPPORTED_CONTENT; + } +#endif *type = image_type; *width = image_w; *height = image_h; |