summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sasyncd
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-08-20 22:39:29 +0000
committerderaadt <deraadt@openbsd.org>2015-08-20 22:39:29 +0000
commit35de856ed2be5e6bd284466437ecec8c238ee751 (patch)
tree52317c381e559008ce133dcf7b89f7ed3ce53858 /usr.sbin/sasyncd
parentDo not cast result of malloc/calloc/realloc* if stdlib.h is in scope (diff)
downloadwireguard-openbsd-35de856ed2be5e6bd284466437ecec8c238ee751.tar.xz
wireguard-openbsd-35de856ed2be5e6bd284466437ecec8c238ee751.zip
stdlib.h is in scope; do not cast malloc/calloc/realloc*
ok millert krw
Diffstat (limited to 'usr.sbin/sasyncd')
-rw-r--r--usr.sbin/sasyncd/conf.y8
-rw-r--r--usr.sbin/sasyncd/monitor.c6
-rw-r--r--usr.sbin/sasyncd/net.c19
-rw-r--r--usr.sbin/sasyncd/net_ctl.c4
-rw-r--r--usr.sbin/sasyncd/pfkey.c10
-rw-r--r--usr.sbin/sasyncd/sasyncd.c6
-rw-r--r--usr.sbin/sasyncd/timer.c4
7 files changed, 28 insertions, 29 deletions
diff --git a/usr.sbin/sasyncd/conf.y b/usr.sbin/sasyncd/conf.y
index fb3a0b2b365..5be15a4e5e7 100644
--- a/usr.sbin/sasyncd/conf.y
+++ b/usr.sbin/sasyncd/conf.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.y,v 1.17 2012/12/21 13:53:01 gsoares Exp $ */
+/* $OpenBSD: conf.y,v 1.18 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -33,6 +33,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
@@ -182,8 +183,7 @@ setting : INTERFACE STRING
if (duplicate)
free($2);
else {
- peer = (struct syncpeer *)calloc(1,
- sizeof *peer);
+ peer = calloc(1, sizeof *peer);
if (!peer) {
log_err("config: calloc(1, %lu) "
"failed", sizeof *peer);
@@ -372,7 +372,7 @@ conf_parse_file(char *cfgfile)
goto bad;
conflen = st.st_size;
- buf = (char *)malloc(conflen + 1);
+ buf = malloc(conflen + 1);
if (!buf) {
log_err("malloc(%d) failed", conflen + 1);
close(fd);
diff --git a/usr.sbin/sasyncd/monitor.c b/usr.sbin/sasyncd/monitor.c
index 27c734ed7ef..a02ab5dc3d0 100644
--- a/usr.sbin/sasyncd/monitor.c
+++ b/usr.sbin/sasyncd/monitor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.c,v 1.19 2015/01/16 06:40:20 deraadt Exp $ */
+/* $OpenBSD: monitor.c,v 1.20 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -277,7 +277,7 @@ monitor_get_pfkey_snap(u_int8_t **sadb, u_int32_t *sadbsize, u_int8_t **spd,
if (m_read(m_state.s, sadbsize, sizeof *sadbsize) < 1)
return -1;
if (*sadbsize) {
- *sadb = (u_int8_t *)malloc(*sadbsize);
+ *sadb = malloc(*sadbsize);
if (!*sadb) {
log_err("monitor_get_pfkey_snap: malloc()");
monitor_drain_input();
@@ -300,7 +300,7 @@ monitor_get_pfkey_snap(u_int8_t **sadb, u_int32_t *sadbsize, u_int8_t **spd,
return -1;
}
if (*spdsize) {
- *spd = (u_int8_t *)malloc(*spdsize);
+ *spd = malloc(*spdsize);
if (!*spd) {
log_err("monitor_get_pfkey_snap: malloc()");
monitor_drain_input();
diff --git a/usr.sbin/sasyncd/net.c b/usr.sbin/sasyncd/net.c
index 3fabe2f05dd..507a7ba3d12 100644
--- a/usr.sbin/sasyncd/net.c
+++ b/usr.sbin/sasyncd/net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net.c,v 1.21 2014/07/04 22:32:29 guenther Exp $ */
+/* $OpenBSD: net.c,v 1.22 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -86,7 +86,7 @@ dump_buf(int lvl, u_int8_t *b, u_int32_t len, char *title)
return;
blen = 2 * (len + len / 36) + 3 + (title ? strlen(title) : sizeof def);
- if (!(buf = (u_int8_t *)calloc(1, blen)))
+ if (!(buf = calloc(1, blen)))
return;
snprintf(buf, blen, "%s\n ", title ? title : def);
@@ -162,7 +162,7 @@ net_setup_listeners(void)
/* Setup listening sockets. */
memset(&sa_storage, 0, sizeof sa_storage);
if (net_set_sa(sa, cfgstate.listen_on, cfgstate.listen_port) == 0) {
- listeners = (int *)calloc(2, sizeof(int));
+ listeners = calloc(2, sizeof(int));
if (!listeners) {
perror("net_setup_listeners: calloc()");
goto errout;
@@ -208,7 +208,7 @@ net_setup_listeners(void)
}
/* Allocate one extra slot and set to -1, marking end of array. */
- listeners = (int *)calloc(count + 1, sizeof(int));
+ listeners = calloc(count + 1, sizeof(int));
if (!listeners) {
perror("net_setup_listeners: calloc()");
goto errout;
@@ -330,7 +330,7 @@ net_queue(struct syncpeer *p0, u_int32_t msgtype, u_int8_t *buf, u_int32_t len)
u_int32_t v, padlen = 0;
int i, offset;
- m = (struct msg *)calloc(1, sizeof *m);
+ m = calloc(1, sizeof *m);
if (!m) {
log_err("net_queue: calloc()");
free(buf);
@@ -376,7 +376,7 @@ net_queue(struct syncpeer *p0, u_int32_t msgtype, u_int8_t *buf, u_int32_t len)
/* Allocate send buffer */
m->len = len + sizeof iv + sizeof hash + 3 * sizeof(u_int32_t);
- m->buf = (u_int8_t *)malloc(m->len);
+ m->buf = malloc(m->len);
if (!m->buf) {
free(m);
free(buf);
@@ -687,7 +687,7 @@ net_read(struct syncpeer *p, u_int32_t *msgtype, u_int32_t *msglen)
return NULL;
/* Read message blob */
- blob = (u_int8_t *)malloc(blob_len);
+ blob = malloc(blob_len);
if (!blob) {
log_err("net_read: malloc()");
return NULL;
@@ -725,7 +725,7 @@ net_read(struct syncpeer *p, u_int32_t *msgtype, u_int32_t *msglen)
rhash = blob + offset;
iv = rhash + sizeof hash;
- msg = (u_int8_t *)malloc(*msglen);
+ msg = malloc(*msglen);
if (!msg) {
free(blob);
return NULL;
@@ -807,8 +807,7 @@ net_connect(void)
if (p->socket > -1)
continue;
if (!p->sa) {
- p->sa = (void *)calloc(1,
- sizeof(struct sockaddr_storage));
+ p->sa = calloc(1, sizeof(struct sockaddr_storage));
if (!p->sa)
return;
if (net_set_sa(p->sa, p->name, cfgstate.listen_port))
diff --git a/usr.sbin/sasyncd/net_ctl.c b/usr.sbin/sasyncd/net_ctl.c
index d79052259fc..b8d3296a4b7 100644
--- a/usr.sbin/sasyncd/net_ctl.c
+++ b/usr.sbin/sasyncd/net_ctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net_ctl.c,v 1.9 2010/06/29 18:10:04 kjell Exp $ */
+/* $OpenBSD: net_ctl.c,v 1.10 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -155,7 +155,7 @@ net_ctl_handle_msg(struct syncpeer *p, u_int8_t *msg, u_int32_t msglen)
static int
net_ctl_send(struct syncpeer *p, u_int32_t type, u_int32_t d, u_int32_t d2)
{
- struct ctlmsg *m = (struct ctlmsg *)malloc(sizeof *m);
+ struct ctlmsg *m = malloc(sizeof *m);
if (!m) {
log_err("malloc(%u)", sizeof *m);
diff --git a/usr.sbin/sasyncd/pfkey.c b/usr.sbin/sasyncd/pfkey.c
index a0ee2d80276..7e91fdc7122 100644
--- a/usr.sbin/sasyncd/pfkey.c
+++ b/usr.sbin/sasyncd/pfkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkey.c,v 1.23 2015/01/16 06:40:20 deraadt Exp $ */
+/* $OpenBSD: pfkey.c,v 1.24 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -110,7 +110,7 @@ pfkey_set_promisc(void)
static void
pfkey_send_flush(struct syncpeer *p)
{
- struct sadb_msg *m = (struct sadb_msg *)calloc(1, sizeof *m);
+ struct sadb_msg *m = calloc(1, sizeof *m);
static u_int32_t seq = 1;
if (m) {
@@ -412,7 +412,7 @@ pfkey_queue_message(u_int8_t *data, u_int32_t datalen)
struct sadb_msg *sadb = (struct sadb_msg *)data;
static u_int32_t seq = 1;
- pmsg = (struct pfkey_msg *)malloc(sizeof *pmsg);
+ pmsg = malloc(sizeof *pmsg);
if (!pmsg) {
log_err("malloc()");
return -1;
@@ -486,7 +486,7 @@ pfkey_snapshot(void *v)
continue;
/* Allocate msgbuffer, net_queue() will free it. */
- sendbuf = (u_int8_t *)calloc(m->sadb_msg_len, CHUNK);
+ sendbuf = calloc(m->sadb_msg_len, CHUNK);
if (sendbuf) {
memcpy(sendbuf, m, m->sadb_msg_len * CHUNK);
net_queue(p, MSG_PFKEYDATA, sendbuf,
@@ -516,7 +516,7 @@ pfkey_snapshot(void *v)
continue;
/* Allocate msgbuffer, freed by net_queue(). */
- sendbuf = (u_int8_t *)calloc(m->sadb_msg_len, CHUNK);
+ sendbuf = calloc(m->sadb_msg_len, CHUNK);
if (sendbuf) {
memcpy(sendbuf, m, m->sadb_msg_len * CHUNK);
net_queue(p, MSG_PFKEYDATA, sendbuf,
diff --git a/usr.sbin/sasyncd/sasyncd.c b/usr.sbin/sasyncd/sasyncd.c
index 0efefe182a9..ac17dca53b8 100644
--- a/usr.sbin/sasyncd/sasyncd.c
+++ b/usr.sbin/sasyncd/sasyncd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sasyncd.c,v 1.23 2012/04/14 12:11:08 haesbaert Exp $ */
+/* $OpenBSD: sasyncd.c,v 1.24 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -63,13 +63,13 @@ sasyncd_run(pid_t ppid)
n = getdtablesize();
fdsetsize = howmany(n, NFDBITS) * sizeof(fd_mask);
- rfds = (fd_set *)malloc(fdsetsize);
+ rfds = malloc(fdsetsize);
if (!rfds) {
log_err("malloc(%lu) failed", (unsigned long)fdsetsize);
return -1;
}
- wfds = (fd_set *)malloc(fdsetsize);
+ wfds = malloc(fdsetsize);
if (!wfds) {
log_err("malloc(%lu) failed", (unsigned long)fdsetsize);
free(rfds);
diff --git a/usr.sbin/sasyncd/timer.c b/usr.sbin/sasyncd/timer.c
index 86aaa3df271..d31a7a1d1ad 100644
--- a/usr.sbin/sasyncd/timer.c
+++ b/usr.sbin/sasyncd/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.4 2010/06/29 18:10:04 kjell Exp $ */
+/* $OpenBSD: timer.c,v 1.5 2015/08/20 22:39:29 deraadt Exp $ */
/*
* Copyright (c) 2005 Håkan Olsson. All rights reserved.
@@ -113,7 +113,7 @@ timer_add(char *name, u_int32_t when, void (*function)(void *), void *arg)
struct timeval now, tmp;
struct event *e, *new;
- new = (struct event *)calloc(1, sizeof *new);
+ new = calloc(1, sizeof *new);
if (!new) {
log_err("timer_add: calloc (1, %u) failed", sizeof *new);
return -1;