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 efa648d..00857e4 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;