summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorRicardo Mestre <mestre@cvs.openbsd.org>2016-10-20 21:09:47 +0000
committerRicardo Mestre <mestre@cvs.openbsd.org>2016-10-20 21:09:47 +0000
commit1f5e77203819b4c2627dcfab35f20a5efd105357 (patch)
tree3810d7ec6c5e532ea2d70b3d00b9a375bddb2afd /libexec
parent907d9e920192b698cb7e3427bb036c8a0daf8793 (diff)
- Remove useless var assignment
- Use memset(*b, 0, len) instead of bzero(*b, len) - Use memcpy(*dst, *src, len) instead of bcopy(*src, *dst, len) - Use explicit_bzero(3) instead of bzero(3) to clean temporary HMAC Remarks from deraadt@ (duly noted!!), reviewed and OK by henning@ and tb@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/spamd/grey.c4
-rw-r--r--libexec/spamd/sync.c34
2 files changed, 18 insertions, 20 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c
index d36288cbdd8..cb375af1318 100644
--- a/libexec/spamd/grey.c
+++ b/libexec/spamd/grey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grey.c,v 1.63 2016/03/25 16:31:32 mestre Exp $ */
+/* $OpenBSD: grey.c,v 1.64 2016/10/20 21:09:46 mestre Exp $ */
/*
* Copyright (c) 2004-2006 Bob Beck. All rights reserved.
@@ -598,7 +598,6 @@ greyscan(char *dbname)
freeaddrlists();
free(a);
a = NULL;
- asiz = 0;
return(0);
bad:
(void) do_changes(db);
@@ -607,7 +606,6 @@ greyscan(char *dbname)
freeaddrlists();
free(a);
a = NULL;
- asiz = 0;
return(-1);
}
diff --git a/libexec/spamd/sync.c b/libexec/spamd/sync.c
index 3c90f5e73bd..7b54ae3bbb5 100644
--- a/libexec/spamd/sync.c
+++ b/libexec/spamd/sync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sync.c,v 1.11 2014/11/23 21:19:47 guenther Exp $ */
+/* $OpenBSD: sync.c,v 1.12 2016/10/20 21:09:46 mestre Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -72,7 +72,7 @@ sync_addhost(const char *name, u_short port)
struct sync_host *shost;
struct sockaddr_in *addr = NULL;
- bzero(&hints, sizeof(hints));
+ memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if (getaddrinfo(name, NULL, &hints, &res0) != 0)
@@ -128,7 +128,7 @@ sync_init(const char *iface, const char *baddr, u_short port)
if (iface != NULL)
sendmcast++;
- bzero(&ina, sizeof(ina));
+ memset(&ina, 0, sizeof(ina));
if (baddr != NULL) {
if (inet_pton(AF_INET, baddr, &ina) != 1) {
ina.s_addr = htonl(INADDR_ANY);
@@ -161,7 +161,7 @@ sync_init(const char *iface, const char *baddr, u_short port)
sizeof(one)) == -1)
goto fail;
- bzero(&sync_out, sizeof(sync_out));
+ memset(&sync_out, 0, sizeof(sync_out));
sync_out.sin_family = AF_INET;
sync_out.sin_len = sizeof(sync_out);
sync_out.sin_addr.s_addr = ina.s_addr;
@@ -189,19 +189,19 @@ sync_init(const char *iface, const char *baddr, u_short port)
}
}
- bzero(&ifr, sizeof(ifr));
+ memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifnam, sizeof(ifr.ifr_name));
if (ioctl(syncfd, SIOCGIFADDR, &ifr) == -1)
goto fail;
- bzero(&sync_in, sizeof(sync_in));
+ memset(&sync_in, 0, sizeof(sync_in));
addr = (struct sockaddr_in *)&ifr.ifr_addr;
sync_in.sin_family = AF_INET;
sync_in.sin_len = sizeof(sync_in);
sync_in.sin_addr.s_addr = addr->sin_addr.s_addr;
sync_in.sin_port = htons(port);
- bzero(&mreq, sizeof(mreq));
+ memset(&mreq, 0, sizeof(mreq));
sync_out.sin_addr.s_addr = inet_addr(SPAM_SYNC_MCASTADDR);
mreq.imr_multiaddr.s_addr = inet_addr(SPAM_SYNC_MCASTADDR);
mreq.imr_interface.s_addr = sync_in.sin_addr.s_addr;
@@ -252,8 +252,8 @@ sync_recv(void)
u_int hmac_len;
u_int32_t expire;
- bzero(&addr, sizeof(addr));
- bzero(buf, sizeof(buf));
+ memset(&addr, 0, sizeof(addr));
+ memset(buf, 0, sizeof(buf));
addr_len = sizeof(addr);
if ((len = recvfrom(syncfd, buf, sizeof(buf), 0,
@@ -274,8 +274,8 @@ sync_recv(void)
len = ntohs(hdr->sh_length);
/* Compute and validate HMAC */
- bcopy(hdr->sh_hmac, hmac[0], SPAM_SYNC_HMAC_LEN);
- bzero(hdr->sh_hmac, SPAM_SYNC_HMAC_LEN);
+ memcpy(hmac[0], hdr->sh_hmac, SPAM_SYNC_HMAC_LEN);
+ explicit_bzero(hdr->sh_hmac, SPAM_SYNC_HMAC_LEN);
HMAC(EVP_sha1(), sync_key, strlen(sync_key), buf, len,
hmac[1], &hmac_len);
if (bcmp(hmac[0], hmac[1], SPAM_SYNC_HMAC_LEN) != 0)
@@ -392,7 +392,7 @@ sync_send(struct iovec *iov, int iovlen)
struct msghdr msg;
/* setup buffer */
- bzero(&msg, sizeof(msg));
+ memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = iovlen;
@@ -432,9 +432,9 @@ sync_update(time_t now, char *helo, char *ip, char *from, char *to)
"sync grey update helo %s ip %s from %s to %s\n",
helo, ip, from, to);
- bzero(&hdr, sizeof(hdr));
- bzero(&sg, sizeof(sg));
- bzero(&pad, sizeof(pad));
+ memset(&hdr, 0, sizeof(hdr));
+ memset(&sg, 0, sizeof(sg));
+ memset(&pad, 0, sizeof(pad));
fromlen = strlen(from) + 1;
tolen = strlen(to) + 1;
@@ -519,8 +519,8 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16_t type)
fprintf(stderr, "sync %s %s\n",
type == SPAM_SYNC_WHITE ? "white" : "trapped", ip);
- bzero(&hdr, sizeof(hdr));
- bzero(&sd, sizeof(sd));
+ memset(&hdr, 0, sizeof(hdr));
+ memset(&sd, 0, sizeof(sd));
HMAC_CTX_init(&ctx);
HMAC_Init(&ctx, sync_key, strlen(sync_key), EVP_sha1());