summaryrefslogtreecommitdiff
path: root/curvetun_server.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 /curvetun_server.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 'curvetun_server.c')
-rw-r--r--curvetun_server.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/curvetun_server.c b/curvetun_server.c
index 36a55fe..c1d5477 100644
--- a/curvetun_server.c
+++ b/curvetun_server.c
@@ -638,7 +638,7 @@ int server_main(char *home, char *dev, char *port, int udp, int ipv4, int log)
set_nonblocking(lfd);
- events = xzmalloc(MAX_EPOLL_SIZE * sizeof(*events));
+ events = xcalloc(MAX_EPOLL_SIZE, sizeof(*events));
for (i = 0; i < MAX_EPOLL_SIZE; ++i)
events[i].data.fd = -1;
@@ -661,7 +661,7 @@ int server_main(char *home, char *dev, char *port, int udp, int ipv4, int log)
if (!ispow2(threads))
syslog_panic("Thread number not power of two!\n");
- threadpool = xzmalloc(sizeof(*threadpool) * threads);
+ threadpool = xcalloc(threads, sizeof(*threadpool));
thread_spawn_or_panic(cpus, efd[1], refd[1], tunfd, ipv4, udp);
init_cpusched(threads);