aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/utils/s2n_array.c
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2022-10-19 19:34:47 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2022-10-19 19:34:47 +0300
commita42f7e7e0064e0d5bc54bde4506539d4766e1356 (patch)
tree348bb42084aed2b557684fbe188656938ab1a492 /contrib/restricted/aws/s2n/utils/s2n_array.c
parentcd66afc0fd1f9359cdf239e4a4f3a345b174e00e (diff)
downloadydb-a42f7e7e0064e0d5bc54bde4506539d4766e1356.tar.gz
Update contrib/restricted/aws/s2n to 1.3.24
Diffstat (limited to 'contrib/restricted/aws/s2n/utils/s2n_array.c')
-rw-r--r--contrib/restricted/aws/s2n/utils/s2n_array.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/restricted/aws/s2n/utils/s2n_array.c b/contrib/restricted/aws/s2n/utils/s2n_array.c
index 0a7f185fc2..1df7f1e101 100644
--- a/contrib/restricted/aws/s2n/utils/s2n_array.c
+++ b/contrib/restricted/aws/s2n/utils/s2n_array.c
@@ -121,9 +121,11 @@ S2N_RESULT s2n_array_insert(struct s2n_array *array, uint32_t idx, void **elemen
/* If we are adding at an existing index, slide everything down. */
if (idx < array->len) {
+ uint32_t size = 0;
+ RESULT_GUARD_POSIX(s2n_mul_overflow(array->len - idx, array->element_size, &size));
memmove(array->mem.data + array->element_size * (idx + 1),
array->mem.data + array->element_size * idx,
- (array->len - idx) * array->element_size);
+ size);
}
*element = array->mem.data + array->element_size * idx;
@@ -141,9 +143,11 @@ S2N_RESULT s2n_array_remove(struct s2n_array *array, uint32_t idx)
/* If the removed element is the last one, no need to move anything.
* Otherwise, shift everything down */
if (idx != array->len - 1) {
+ uint32_t size = 0;
+ RESULT_GUARD_POSIX(s2n_mul_overflow(array->len - idx - 1, array->element_size, &size));
memmove(array->mem.data + array->element_size * idx,
array->mem.data + array->element_size * (idx + 1),
- (array->len - idx - 1) * array->element_size);
+ size);
}
array->len--;