From: Michal Schmidt Date: Tue, 21 Oct 2014 12:36:03 +0000 (+0200) Subject: strv: use realloc_multiply() to check for multiplication overflow X-Git-Tag: v217~175 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=14f27b4e3b009d10bb9a3b43b74585c73a7c7626;p=elogind.git strv: use realloc_multiply() to check for multiplication overflow This could overflow on 32bit, where size_t is the same as unsigned. --- diff --git a/src/shared/strv.c b/src/shared/strv.c index efa648df8..00857e40a 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -392,7 +392,7 @@ int strv_push(char ***l, char *value) { if (m < n) return -ENOMEM; - c = realloc(*l, sizeof(char*) * (size_t) m); + c = realloc_multiply(*l, sizeof(char*), m); if (!c) return -ENOMEM;