Commit 00f084b6ec75bc025c20411f4946bba69d14a33a

Ran Benita 2014-04-22T14:34:57

utils: detect overflow in memdup() Signed-off-by: Ran Benita <ran234@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/utils.h b/src/utils.h
index 878c2ac..0198f07 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -99,7 +99,7 @@ strempty(const char *s)
 static inline void *
 memdup(const void *mem, size_t nmemb, size_t size)
 {
-    void *p = malloc(nmemb * size);
+    void *p = calloc(nmemb, size);
     if (p)
         memcpy(p, mem, nmemb * size);
     return p;