chiark / gitweb /
strv: use realloc_multiply() to check for multiplication overflow
authorMichal Schmidt <mschmidt@redhat.com>
Tue, 21 Oct 2014 12:36:03 +0000 (14:36 +0200)
committerMichal Schmidt <mschmidt@redhat.com>
Tue, 21 Oct 2014 12:36:03 +0000 (14:36 +0200)
This could overflow on 32bit, where size_t is the same as unsigned.

src/shared/strv.c

index efa648df88c1a0857fb9a61c40661e2a69cdf3f6..00857e40a7a3b500865c9516a2bc69fd25a8432e 100644 (file)
@@ -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;