darray: check integer overflow 07/318207/3 accepted/tizen_9.0_unified accepted/tizen_unified accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen tizen_9.0 accepted/tizen/9.0/unified/20241030.231557 accepted/tizen/unified/20240927.171126 accepted/tizen/unified/toolchain/20241004.101829 accepted/tizen/unified/x/20240929.082835 accepted/tizen/unified/x/asan/20241014.000209 tizen_9.0_m2_release
authorduna.oh <duna.oh@samsung.com>
Wed, 25 Sep 2024 11:27:11 +0000 (20:27 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Sep 2024 02:29:20 +0000 (11:29 +0900)
commit00203d5022219895e2885c86ef773cbf58feb495
treee52785ae2a5f8674ac469e45ca1d77fdf62ece95
parent63d9d57f04c1b16e370fa28b328fc33489819e07
darray: check integer overflow

In commit b9b3593cbdeb7f5b02d50cecaba6a0b47d4979ad,
darray is changed to use unsigned int instead of size_t
to reduce memory usage.
However, an integer overflow may occur due to arithmetic operation
(addition) between values.

To address this issue, this commit adds checks if this sums don't
exceed their type's maximum value.

Change-Id: Iaa689bb3beff0f991c8b9b6d8fc541f971d8c735
src/darray.h