summaryrefslogtreecommitdiff
path: root/ifpps.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-06-24 19:06:05 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-06-25 10:18:09 +0200
commit46b0ace509d9ed013915e9ab8013c7c712e11395 (patch)
treea2882741a458995c1d3303bf87e6c88ea17724a2 /ifpps.c
parent6424dd90f721fd968c1159236f525ed59f355045 (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 'ifpps.c')
-rw-r--r--ifpps.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ifpps.c b/ifpps.c
index 4cdcbf4..77c63a6 100644
--- a/ifpps.c
+++ b/ifpps.c
@@ -173,7 +173,7 @@ static inline int padding_from_num(int n)
}
#define STATS_ALLOC1(member) \
- do { stats->member = xzmalloc(cpus * sizeof(*(stats->member))); } while (0)
+ do { stats->member = xcalloc(cpus, sizeof(*(stats->member))); } while (0)
static void stats_alloc(struct ifstat *stats, unsigned int cpus)
{
@@ -1425,7 +1425,7 @@ int main(int argc, char **argv)
stats_alloc(&stats_new, cpus);
stats_alloc(&stats_delta, cpus);
- cpu_hits = xzmalloc(cpus * sizeof(*cpu_hits));
+ cpu_hits = xcalloc(cpus, sizeof(*cpu_hits));
if (promisc)
ifflags = device_enter_promiscuous_mode(ifname);