diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2014-06-24 19:06:05 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2014-06-25 10:18:09 +0200 |
commit | 46b0ace509d9ed013915e9ab8013c7c712e11395 (patch) | |
tree | a2882741a458995c1d3303bf87e6c88ea17724a2 /astraceroute.c | |
parent | 6424dd90f721fd968c1159236f525ed59f355045 (diff) |
xmalloc: Add and use xcalloc
Add a wrapper for calloc which checks for integer overflows in the
calculation of the size to allocate.
Use xcalloc to allocate an array of objects instead of calculating the
size ourselves, which might cause an integer overflow.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'astraceroute.c')
-rw-r--r-- | astraceroute.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/astraceroute.c b/astraceroute.c index 2f3449e..da922c6 100644 --- a/astraceroute.c +++ b/astraceroute.c @@ -785,7 +785,7 @@ static int __process_time(struct ctx *ctx, int fd, int fd_cap, int ttl, return -EIO; } - tmp = xmalloc(sizeof(struct timeval) * good); + tmp = xcalloc(good, sizeof(struct timeval)); for (i = j = 0; i < array_size(probes); ++i) { if (probes[i].tv_sec == 0 && probes[i].tv_usec == 0) continue; |