From 7bcbf20b3d3f851a541cf3381bac1ddef04f1488 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 28 Jan 2020 11:06:59 +0100 Subject: [PATCH] array: Avoid overflow in size calculation While it's unlikely that so many (large) items are allocated, this is technically more correct. The result previously could overflow an unsigned int (the conversion to size_t happened afterwards). --- src/libstrongswan/collections/array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstrongswan/collections/array.c b/src/libstrongswan/collections/array.c index fea28cedb..93c35bc12 100644 --- a/src/libstrongswan/collections/array.c +++ b/src/libstrongswan/collections/array.c @@ -68,7 +68,7 @@ static size_t get_size(array_t *array, uint32_t num) { if (array->esize) { - return array->esize * num; + return (size_t)array->esize * num; } return sizeof(void*) * num; }