From eafe309e35977891f1b9cf639e7c1bffb25da0dd Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 17 Aug 2022 15:15:25 +0000 Subject: [PATCH] Convert bzero() to memset(), bcmp() to memcmp() and bcopy() to memcpy(). The memory regions passed to memcpy() can not overlap so no need for memmove(). OK tb@ deraadt@ --- usr.sbin/bgpd/bgpd.c | 4 ++-- usr.sbin/bgpd/carp.c | 6 +++--- usr.sbin/bgpd/config.c | 6 +++--- usr.sbin/bgpd/control.c | 6 +++--- usr.sbin/bgpd/kroute.c | 44 +++++++++++++++++++------------------- usr.sbin/bgpd/mrt.c | 8 +++---- usr.sbin/bgpd/parse.y | 22 +++++++++---------- usr.sbin/bgpd/pfkey.c | 38 ++++++++++++++++---------------- usr.sbin/bgpd/pftable.c | 10 ++++----- usr.sbin/bgpd/rde.c | 28 ++++++++++++------------ usr.sbin/bgpd/rde_peer.c | 4 ++-- usr.sbin/bgpd/rde_prefix.c | 10 ++++----- usr.sbin/bgpd/rde_update.c | 14 ++++++------ usr.sbin/bgpd/rtr.c | 4 ++-- usr.sbin/bgpd/session.c | 14 ++++++------ usr.sbin/bgpd/util.c | 16 +++++++------- 16 files changed, 117 insertions(+), 117 deletions(-) diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 313c959f8b0..8632d76ebec 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.253 2022/07/28 13:11:48 deraadt Exp $ */ +/* $OpenBSD: bgpd.c,v 1.254 2022/08/17 15:15:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -321,7 +321,7 @@ BROKEN if (pledge("stdio rpath wpath cpath fattr unix route recvfd sendfd", pfd = newp; pfd_elms = PFD_CONNECT_START + connect_cnt; } - bzero(pfd, sizeof(struct pollfd) * pfd_elms); + memset(pfd, 0, sizeof(struct pollfd) * pfd_elms); timeout = mrt_timeout(conf->mrt); diff --git a/usr.sbin/bgpd/carp.c b/usr.sbin/bgpd/carp.c index 64aec7d87f5..e25d03be688 100644 --- a/usr.sbin/bgpd/carp.c +++ b/usr.sbin/bgpd/carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: carp.c,v 1.10 2019/08/08 20:06:29 claudio Exp $ */ +/* $OpenBSD: carp.c,v 1.11 2022/08/17 15:15:25 claudio Exp $ */ /* * Copyright (c) 2006 Henning Brauer @@ -113,7 +113,7 @@ carp_demote_get(char *group) return (-1); } - bzero(&ifgr, sizeof(ifgr)); + memset(&ifgr, 0, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)); if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1) { @@ -167,7 +167,7 @@ carp_demote_ioctl(char *group, int demote) return (-1); } - bzero(&ifgr, sizeof(ifgr)); + memset(&ifgr, 0, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)); ifgr.ifgr_attrib.ifg_carp_demoted = demote; diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c index 035252ea601..d6f2163b750 100644 --- a/usr.sbin/bgpd/config.c +++ b/usr.sbin/bgpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.103 2022/07/20 12:43:27 claudio Exp $ */ +/* $OpenBSD: config.c,v 1.104 2022/08/17 15:15:25 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -409,7 +409,7 @@ host(const char *s, struct bgpd_addr *h, uint8_t *len) p[0] = '\0'; } - bzero(h, sizeof(*h)); + memset(h, 0, sizeof(*h)); if (host_ip(ps, h, len) == 0) { free(ps); @@ -429,7 +429,7 @@ host_ip(const char *s, struct bgpd_addr *h, uint8_t *len) struct addrinfo hints, *res; int bits; - bzero(&hints, sizeof(hints)); + memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; /*dummy*/ hints.ai_flags = AI_NUMERICHOST; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index d67606e252b..014b9b17bd8 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.107 2022/07/28 13:11:48 deraadt Exp $ */ +/* $OpenBSD: control.c,v 1.108 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -45,7 +45,7 @@ control_check(char *path) struct sockaddr_un sa_un; int fd; - bzero(&sa_un, sizeof(sa_un)); + memset(&sa_un, 0, sizeof(sa_un)); sa_un.sun_family = AF_UNIX; strlcpy(sa_un.sun_path, path, sizeof(sa_un.sun_path)); @@ -78,7 +78,7 @@ control_init(int restricted, char *path) return (-1); } - bzero(&sa_un, sizeof(sa_un)); + memset(&sa_un, 0, sizeof(sa_un)); sa_un.sun_family = AF_UNIX; if (strlcpy(sa_un.sun_path, path, sizeof(sa_un.sun_path)) >= sizeof(sa_un.sun_path)) { diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 320b16257ff..aed7f4b047c 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.291 2022/08/17 10:54:52 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.292 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker @@ -272,7 +272,7 @@ ktable_new(u_int rtableid, u_int rdomid, char *name, int fs) } krt = xkrt; krt_size = rtableid + 1; - bzero((char *)krt + oldsize, + memset((char *)krt + oldsize, 0, krt_size * sizeof(struct ktable *) - oldsize); } @@ -512,7 +512,7 @@ kr6_change(struct ktable *kt, struct kroute_full *kf) /* for blackhole and reject routes nexthop needs to be ::1 */ if (kf->flags & (F_BLACKHOLE|F_REJECT)) - bcopy(&lo6, &kf->nexthop.v6, sizeof(kf->nexthop.v6)); + memcpy(&kf->nexthop.v6, &lo6, sizeof(kf->nexthop.v6)); /* nexthop to loopback -> ignore silently */ else if (IN6_IS_ADDR_LOOPBACK(&kf->nexthop.v6)) return (0); @@ -618,7 +618,7 @@ krVPN6_change(struct ktable *kt, struct kroute_full *kf) /* for blackhole and reject routes nexthop needs to be ::1 */ if (kf->flags & (F_BLACKHOLE|F_REJECT)) - bcopy(&lo6, &kf->nexthop.v6, sizeof(kf->nexthop.v6)); + memcpy(&kf->nexthop.v6, &lo6, sizeof(kf->nexthop.v6)); if ((kr6 = kroute6_find(kt, &kf->prefix, kf->prefixlen, kf->priority)) == NULL) { @@ -840,7 +840,7 @@ kr_show_interface(struct kif *kif) static struct ctl_show_interface iface; uint64_t ifms_type; - bzero(&iface, sizeof(iface)); + memset(&iface, 0, sizeof(iface)); strlcpy(iface.ifname, kif->ifname, sizeof(iface.ifname)); snprintf(iface.linkstate, sizeof(iface.linkstate), @@ -957,7 +957,7 @@ kr_show_route(struct imsg *imsg) break; } RB_FOREACH(h, knexthop_tree, KT2KNT(kt)) { - bzero(&snh, sizeof(snh)); + memset(&snh, 0, sizeof(snh)); memcpy(&snh.addr, &h->nexthop, sizeof(snh.addr)); if (h->kroute != NULL) { switch (h->nexthop.aid) { @@ -1081,7 +1081,7 @@ kr_net_redist_del(struct ktable *kt, struct network_config *net, int dynamic) { struct kredist_node *r, node; - bzero(&node, sizeof(node)); + memset(&node, 0, sizeof(node)); node.prefix = net->prefix; node.prefixlen = net->prefixlen; node.rd = net->rd; @@ -1214,7 +1214,7 @@ kr_redistribute(int type, struct ktable *kt, struct kroute_full *kf) uint32_t a; int loflag = 0; - bzero(&net, sizeof(net)); + memset(&net, 0, sizeof(net)); net.prefix = kf->prefix; net.prefixlen = kf->prefixlen; net.rtlabel = rtlabel_name2id(kf->label); @@ -1382,7 +1382,7 @@ kr_tofull(struct kroute *kr) { static struct kroute_full kf; - bzero(&kf, sizeof(kf)); + memset(&kf, 0, sizeof(kf)); kf.prefix.aid = AID_INET; kf.prefix.v4.s_addr = kr->prefix.s_addr; @@ -1403,7 +1403,7 @@ kr6_tofull(struct kroute6 *kr6) { static struct kroute_full kf; - bzero(&kf, sizeof(kf)); + memset(&kf, 0, sizeof(kf)); kf.prefix.aid = AID_INET6; kf.prefix.v6 = kr6->prefix; @@ -1952,7 +1952,7 @@ knexthop_find(struct ktable *kt, struct bgpd_addr *addr) { struct knexthop s; - bzero(&s, sizeof(s)); + memset(&s, 0, sizeof(s)); memcpy(&s.nexthop, addr, sizeof(s.nexthop)); return (RB_FIND(knexthop_tree, KT2KNT(kt), &s)); @@ -1995,7 +1995,7 @@ kif_find(int ifindex) { struct kif s; - bzero(&s, sizeof(s)); + memset(&s, 0, sizeof(s)); s.ifindex = ifindex; return (RB_FIND(kif_tree, &kit, &s)); @@ -2592,8 +2592,8 @@ get_mpe_config(const char *name, u_int *rdomain, u_int *label) if (s == -1) return (-1); - bzero(&shim, sizeof(shim)); - bzero(&ifr, sizeof(ifr)); + memset(&shim, 0, sizeof(shim)); + memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t)&shim; @@ -2639,7 +2639,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) return (0); /* initialize header */ - bzero(&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.rtm_version = RTM_VERSION; hdr.rtm_type = action; hdr.rtm_tableid = kt->rtableid; @@ -2656,7 +2656,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) iov[iovcnt].iov_base = &hdr; iov[iovcnt++].iov_len = sizeof(hdr); - bzero(&prefix, sizeof(prefix)); + memset(&prefix, 0, sizeof(prefix)); sa = addr2sa(&kf->prefix, 0, &salen); sa->sa_len = salen; #ifdef __KAME__ @@ -2680,7 +2680,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) /* XXX can we even have no nexthop ??? */ if (kf->nexthop.aid != AID_UNSPEC) { - bzero(&nexthop, sizeof(nexthop)); + memset(&nexthop, 0, sizeof(nexthop)); sa = addr2sa(&kf->nexthop, 0, &salen); sa->sa_len = salen; #ifdef __KAME__ @@ -2704,11 +2704,11 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) iov[iovcnt++].iov_len = ROUNDUP(salen); } - bzero(&netmask, sizeof(netmask)); + memset(&netmask, 0, sizeof(netmask)); memset(&netmask.v6, 0xff, sizeof(netmask.v6)); netmask.aid = kf->prefix.aid; applymask(&netmask, &netmask, kf->prefixlen); - bzero(&mask, sizeof(mask)); + memset(&mask, 0, sizeof(mask)); sa = addr2sa(&netmask, 0, &salen); sa->sa_len = salen; memcpy(&mask, sa, salen); @@ -2721,7 +2721,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) if (kf->flags & F_MPLS) { /* need to force interface for mpe(4) routes */ - bzero(&ifp, sizeof(ifp)); + memset(&ifp, 0, sizeof(ifp)); dl = (struct sockaddr_dl *)&ifp; salen = sizeof(*dl); dl->sdl_len = salen; @@ -2734,7 +2734,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) iov[iovcnt].iov_base = &ifp; iov[iovcnt++].iov_len = ROUNDUP(salen); - bzero(&mpls, sizeof(mpls)); + memset(&mpls, 0, sizeof(mpls)); mp = (struct sockaddr_mpls *)&mpls; salen = sizeof(*mp); mp->smpls_len = salen; @@ -2753,7 +2753,7 @@ send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf) } if (kf->label[0] != '\0') { - bzero(&label, sizeof(label)); + memset(&label, 0, sizeof(label)); la = (struct sockaddr_rtlabel *)&label; salen = sizeof(struct sockaddr_rtlabel); label.ss_len = salen; diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index bca78b8d013..c34cedf8768 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.108 2022/07/28 13:11:48 deraadt Exp $ */ +/* $OpenBSD: mrt.c,v 1.109 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -449,7 +449,7 @@ mrt_dump_entry_mp(struct mrt *mrt, struct prefix *p, uint16_t snum, n = prefix_nexthop(p); if (n == NULL) { - bzero(&nexthop, sizeof(struct bgpd_addr)); + memset(&nexthop, 0, sizeof(struct bgpd_addr)); nexthop.aid = addr.aid; nh = &nexthop; } else @@ -543,7 +543,7 @@ mrt_dump_entry(struct mrt *mrt, struct prefix *p, uint16_t snum, nexthop = prefix_nexthop(p); if (nexthop == NULL) { - bzero(&addr, sizeof(struct bgpd_addr)); + memset(&addr, 0, sizeof(struct bgpd_addr)); addr.aid = p->pt->aid; nh = &addr; } else @@ -645,7 +645,7 @@ mrt_dump_entry_v2_rib(struct rib_entry *re, struct ibuf **nb, struct ibuf **apb, nexthop = prefix_nexthop(p); if (nexthop == NULL) { - bzero(&addr, sizeof(struct bgpd_addr)); + memset(&addr, 0, sizeof(struct bgpd_addr)); addr.aid = re->prefix->aid; nh = &addr; } else diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index cb78e0f8f43..a5484cf28ab 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.434 2022/07/28 13:11:49 deraadt Exp $ */ +/* $OpenBSD: parse.y,v 1.435 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -1949,10 +1949,10 @@ espah : ESP { $$ = 1; } ; encspec : /* nada */ { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); } | STRING STRING { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); if (!strcmp($1, "3des") || !strcmp($1, "3des-cbc")) { $$.enc_alg = AUTH_EALG_3DESCBC; $$.enc_key_len = 21; /* XXX verify */ @@ -1990,7 +1990,7 @@ filterrule : action quick filter_rib_h direction filter_peer_h struct filter_rule r; struct filter_rib_l *rb, *rbnext; - bzero(&r, sizeof(r)); + memset(&r, 0, sizeof(r)); r.action = $1; r.quick = $2; r.dir = $4; @@ -2317,10 +2317,10 @@ filter_as : as4number_any { ; filter_match_h : /* empty */ { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); } | { - bzero(&fmopts, sizeof(fmopts)); + memset(&fmopts, 0, sizeof(fmopts)); } filter_match { memcpy(&$$, &fmopts, sizeof($$)); @@ -2568,15 +2568,15 @@ filter_elm : filter_prefix_h { } ; -prefixlenop : /* empty */ { bzero(&$$, sizeof($$)); } +prefixlenop : /* empty */ { memset(&$$, 0, sizeof($$)); } | LONGER { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); $$.op = OP_RANGE; $$.len_min = -1; $$.len_max = -1; } | MAXLEN NUMBER { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); if ($2 < 0 || $2 > 128) { yyerror("prefixlen must be >= 0 and <= 128"); YYERROR; @@ -2589,7 +2589,7 @@ prefixlenop : /* empty */ { bzero(&$$, sizeof($$)); } | PREFIXLEN unaryop NUMBER { int min, max; - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); if ($3 < 0 || $3 > 128) { yyerror("prefixlen must be >= 0 and <= 128"); YYERROR; @@ -2630,7 +2630,7 @@ prefixlenop : /* empty */ { bzero(&$$, sizeof($$)); } $$.len_max = max; } | PREFIXLEN NUMBER binaryop NUMBER { - bzero(&$$, sizeof($$)); + memset(&$$, 0, sizeof($$)); if ($2 < 0 || $2 > 128 || $4 < 0 || $4 > 128) { yyerror("prefixlen must be < 128"); YYERROR; diff --git a/usr.sbin/bgpd/pfkey.c b/usr.sbin/bgpd/pfkey.c index ee4d85de54f..20c684cfd01 100644 --- a/usr.sbin/bgpd/pfkey.c +++ b/usr.sbin/bgpd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.66 2022/07/28 13:11:50 deraadt Exp $ */ +/* $OpenBSD: pfkey.c,v 1.67 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -91,8 +91,8 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, pid = getpid(); /* we need clean sockaddr... no ports set */ - bzero(&ssrc, sizeof(ssrc)); - bzero(&smask, sizeof(smask)); + memset(&ssrc, 0, sizeof(ssrc)); + memset(&smask, 0, sizeof(smask)); if ((saptr = addr2sa(src, 0, &salen))) { memcpy(&ssrc, saptr, salen); ssrc.ss_len = salen; @@ -114,8 +114,8 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, smask.ss_family = ssrc.ss_family; smask.ss_len = ssrc.ss_len; - bzero(&sdst, sizeof(sdst)); - bzero(&dmask, sizeof(dmask)); + memset(&sdst, 0, sizeof(sdst)); + memset(&dmask, 0, sizeof(dmask)); if ((saptr = addr2sa(dst, 0, &salen))) { memcpy(&sdst, saptr, salen); sdst.ss_len = salen; @@ -137,7 +137,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, dmask.ss_family = sdst.ss_family; dmask.ss_len = sdst.ss_len; - bzero(&smsg, sizeof(smsg)); + memset(&smsg, 0, sizeof(smsg)); smsg.sadb_msg_version = PF_KEY_V2; smsg.sadb_msg_seq = ++sadb_msg_seq; smsg.sadb_msg_pid = pid; @@ -147,7 +147,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, switch (mtype) { case SADB_GETSPI: - bzero(&sa_spirange, sizeof(sa_spirange)); + memset(&sa_spirange, 0, sizeof(sa_spirange)); sa_spirange.sadb_spirange_exttype = SADB_EXT_SPIRANGE; sa_spirange.sadb_spirange_len = sizeof(sa_spirange) / 8; sa_spirange.sadb_spirange_min = 0x100; @@ -157,7 +157,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, case SADB_ADD: case SADB_UPDATE: case SADB_DELETE: - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); sa.sadb_sa_exttype = SADB_EXT_SA; sa.sadb_sa_len = sizeof(sa) / 8; sa.sadb_sa_replay = 0; @@ -166,13 +166,13 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, break; case SADB_X_ADDFLOW: case SADB_X_DELFLOW: - bzero(&sa_flowtype, sizeof(sa_flowtype)); + memset(&sa_flowtype, 0, sizeof(sa_flowtype)); sa_flowtype.sadb_protocol_exttype = SADB_X_EXT_FLOW_TYPE; sa_flowtype.sadb_protocol_len = sizeof(sa_flowtype) / 8; sa_flowtype.sadb_protocol_direction = dir; sa_flowtype.sadb_protocol_proto = SADB_X_FLOW_TYPE_REQUIRE; - bzero(&sa_protocol, sizeof(sa_protocol)); + memset(&sa_protocol, 0, sizeof(sa_protocol)); sa_protocol.sadb_protocol_exttype = SADB_X_EXT_PROTOCOL; sa_protocol.sadb_protocol_len = sizeof(sa_protocol) / 8; sa_protocol.sadb_protocol_direction = 0; @@ -180,11 +180,11 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, break; } - bzero(&sa_src, sizeof(sa_src)); + memset(&sa_src, 0, sizeof(sa_src)); sa_src.sadb_address_exttype = SADB_EXT_ADDRESS_SRC; sa_src.sadb_address_len = (sizeof(sa_src) + ROUNDUP(ssrc.ss_len)) / 8; - bzero(&sa_dst, sizeof(sa_dst)); + memset(&sa_dst, 0, sizeof(sa_dst)); sa_dst.sadb_address_exttype = SADB_EXT_ADDRESS_DST; sa_dst.sadb_address_len = (sizeof(sa_dst) + ROUNDUP(sdst.ss_len)) / 8; @@ -194,13 +194,13 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, switch (mtype) { case SADB_ADD: case SADB_UPDATE: - bzero(&sa_akey, sizeof(sa_akey)); + memset(&sa_akey, 0, sizeof(sa_akey)); sa_akey.sadb_key_exttype = SADB_EXT_KEY_AUTH; sa_akey.sadb_key_len = (sizeof(sa_akey) + ((alen + 7) / 8) * 8) / 8; sa_akey.sadb_key_bits = 8 * alen; - bzero(&sa_ekey, sizeof(sa_ekey)); + memset(&sa_ekey, 0, sizeof(sa_ekey)); sa_ekey.sadb_key_exttype = SADB_EXT_KEY_ENCRYPT; sa_ekey.sadb_key_len = (sizeof(sa_ekey) + ((elen + 7) / 8) * 8) / 8; @@ -225,7 +225,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, sa_src.sadb_address_exttype = SADB_X_EXT_SRC_FLOW; sa_dst.sadb_address_exttype = SADB_X_EXT_DST_FLOW; - bzero(&smask, sizeof(smask)); + memset(&smask, 0, sizeof(smask)); switch (src->aid) { case AID_INET: smask.ss_len = sizeof(struct sockaddr_in); @@ -252,7 +252,7 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, } break; } - bzero(&dmask, sizeof(dmask)); + memset(&dmask, 0, sizeof(dmask)); switch (dst->aid) { case AID_INET: dmask.ss_len = sizeof(struct sockaddr_in); @@ -280,12 +280,12 @@ pfkey_send(int sd, uint8_t satype, uint8_t mtype, uint8_t dir, break; } - bzero(&sa_smask, sizeof(sa_smask)); + memset(&sa_smask, 0, sizeof(sa_smask)); sa_smask.sadb_address_exttype = SADB_X_EXT_SRC_MASK; sa_smask.sadb_address_len = (sizeof(sa_smask) + ROUNDUP(smask.ss_len)) / 8; - bzero(&sa_dmask, sizeof(sa_dmask)); + memset(&sa_dmask, 0, sizeof(sa_dmask)); sa_dmask.sadb_address_exttype = SADB_X_EXT_DST_MASK; sa_dmask.sadb_address_len = (sizeof(sa_dmask) + ROUNDUP(dmask.ss_len)) / 8; @@ -432,7 +432,7 @@ pfkey_read(int sd, struct sadb_msg *h) if (hdr.sadb_msg_seq == sadb_msg_seq && hdr.sadb_msg_pid == pid) { if (h) - bcopy(&hdr, h, sizeof(hdr)); + memcpy(h, &hdr, sizeof(hdr)); return (0); } diff --git a/usr.sbin/bgpd/pftable.c b/usr.sbin/bgpd/pftable.c index 86473d7587b..bb60269c3b8 100644 --- a/usr.sbin/bgpd/pftable.c +++ b/usr.sbin/bgpd/pftable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftable.c,v 1.16 2022/02/06 09:51:19 claudio Exp $ */ +/* $OpenBSD: pftable.c,v 1.17 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -66,7 +66,7 @@ pftable_change(struct pf_table *pft) if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); - bzero(&tio, sizeof(tio)); + memset(&tio, 0, sizeof(tio)); strlcpy(tio.pfrio_table.pfrt_name, pft->name, sizeof(tio.pfrio_table.pfrt_name)); tio.pfrio_buffer = pft->worklist; @@ -93,7 +93,7 @@ pftable_clear(const char *name) if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); - bzero(&tio, sizeof(tio)); + memset(&tio, 0, sizeof(tio)); strlcpy(tio.pfrio_table.pfrt_name, name, sizeof(tio.pfrio_table.pfrt_name)); @@ -114,7 +114,7 @@ pftable_exists(const char *name) if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); - bzero(&tio, sizeof(tio)); + memset(&tio, 0, sizeof(tio)); strlcpy(tio.pfrio_table.pfrt_name, name, sizeof(tio.pfrio_table.pfrt_name)); tio.pfrio_buffer = &dummy; @@ -215,7 +215,7 @@ pftable_add_work(const char *table, struct bgpd_addr *addr, pft->worklist = tmp; pfa = &pft->worklist[pft->naddrs]; - bzero(pfa, sizeof(*pfa)); + memset(pfa, 0, sizeof(*pfa)); memcpy(&pfa->pfra_u, &addr->ba, (len + 7U) / 8); pfa->pfra_af = aid2af(addr->aid); pfa->pfra_net = len; diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index bffe049a11d..53b78e345b5 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.563 2022/08/16 08:14:58 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.564 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -230,7 +230,7 @@ rde_main(int debug, int verbose) pfd_elms = PFD_PIPE_COUNT + rde_mrt_cnt; } timeout = -1; - bzero(pfd, sizeof(struct pollfd) * pfd_elms); + memset(pfd, 0, sizeof(struct pollfd) * pfd_elms); set_pollfd(&pfd[PFD_PIPE_MAIN], ibuf_main); set_pollfd(&pfd[PFD_PIPE_SESSION], ibuf_se); @@ -425,7 +425,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) if (imsg.hdr.len - IMSG_HEADER_SIZE < sizeof(csr)) { log_warnx("rde_dispatch: wrong imsg len"); - bzero(&netconf_s, sizeof(netconf_s)); + memset(&netconf_s, 0, sizeof(netconf_s)); break; } aslen = imsg.hdr.len - IMSG_HEADER_SIZE - sizeof(csr); @@ -454,7 +454,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) log_warnx("rde_dispatch: bad network " "attribute"); rde_filterstate_clean(&netconf_state); - bzero(&netconf_s, sizeof(netconf_s)); + memset(&netconf_s, 0, sizeof(netconf_s)); break; } break; @@ -1239,7 +1239,7 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg) } } - bzero(&mpa, sizeof(mpa)); + memset(&mpa, 0, sizeof(mpa)); rde_filterstate_prep(&state, NULL, NULL, NULL, 0); if (attrpath_len != 0) { /* 0 = no NLRI information in this message */ /* parse path attributes */ @@ -1857,7 +1857,7 @@ bad_flags: goto bad_list; a->flags |= F_ATTR_NEXTHOP; - bzero(&nexthop, sizeof(nexthop)); + memset(&nexthop, 0, sizeof(nexthop)); nexthop.aid = AID_INET; UPD_READ(&nexthop.v4.s_addr, p, plen, 4); /* @@ -2212,7 +2212,7 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid, if (nhlen > len) return (-1); - bzero(&nexthop, sizeof(nexthop)); + memset(&nexthop, 0, sizeof(nexthop)); nexthop.aid = aid; switch (aid) { case AID_INET6: @@ -3048,7 +3048,7 @@ rde_send_kroute(struct rib *rib, struct prefix *new, struct prefix *old) p = new; } - bzero(&kf, sizeof(kf)); + memset(&kf, 0, sizeof(kf)); pt_getaddr(p->pt, &kf.prefix); kf.prefixlen = p->pt->prefixlen; if (type == IMSG_KROUTE_CHANGE) { @@ -3158,7 +3158,7 @@ rde_update_queue_runner(void) /* now bgp path attributes unless it is the EoR mark */ if (up_is_eor(peer, AID_INET)) { eor = 1; - bzero(queue_buf + wpos, 2); + memset(queue_buf + wpos, 0, 2); wpos += 2; } else { r = up_dump_attrnlri(queue_buf + wpos, @@ -3293,7 +3293,7 @@ rde_pftable_send(uint16_t id, struct pt_entry *pt, int del) if (rde_quit) return; - bzero(&pfm, sizeof(pfm)); + memset(&pfm, 0, sizeof(pfm)); strlcpy(pfm.pftable, pftable_id2name(id), sizeof(pfm.pftable)); pt_getaddr(pt, &pfm.addr); pfm.len = pt->prefixlen; @@ -4006,7 +4006,7 @@ rde_peer_send_eor(struct rde_peer *peer, uint8_t aid) if (aid == AID_INET) { u_char null[4]; - bzero(&null, 4); + memset(&null, 0, 4); if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, 0, -1, &null, 4) == -1) fatal("imsg_compose error while sending EoR"); @@ -4018,14 +4018,14 @@ rde_peer_send_eor(struct rde_peer *peer, uint8_t aid) fatalx("peer_send_eor: bad AID"); i = 0; /* v4 withdrawn len */ - bcopy(&i, &buf[0], sizeof(i)); + memcpy(&buf[0], &i, sizeof(i)); i = htons(6); /* path attr len */ - bcopy(&i, &buf[2], sizeof(i)); + memcpy(&buf[2], &i, sizeof(i)); buf[4] = ATTR_OPTIONAL; buf[5] = ATTR_MP_UNREACH_NLRI; buf[6] = 3; /* withdrawn len */ i = htons(afi); - bcopy(&i, &buf[7], sizeof(i)); + memcpy(&buf[7], &i, sizeof(i)); buf[9] = safi; if (imsg_compose(ibuf_se, IMSG_UPDATE, peer->conf.id, diff --git a/usr.sbin/bgpd/rde_peer.c b/usr.sbin/bgpd/rde_peer.c index f5d9bc3c6ac..838d0888c95 100644 --- a/usr.sbin/bgpd/rde_peer.c +++ b/usr.sbin/bgpd/rde_peer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_peer.c,v 1.20 2022/07/28 13:11:51 deraadt Exp $ */ +/* $OpenBSD: rde_peer.c,v 1.21 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -99,7 +99,7 @@ peer_init(uint32_t hashsize) peertable.peer_hashmask = hs - 1; - bzero(&pc, sizeof(pc)); + memset(&pc, 0, sizeof(pc)); snprintf(pc.descr, sizeof(pc.descr), "LOCAL"); pc.id = PEER_ID_SELF; diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index 6e0805dda7d..3a85cd85726 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.41 2022/02/25 12:56:12 claudio Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.42 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -72,7 +72,7 @@ pt_shutdown(void) void pt_getaddr(struct pt_entry *pte, struct bgpd_addr *addr) { - bzero(addr, sizeof(struct bgpd_addr)); + memset(addr, 0, sizeof(struct bgpd_addr)); addr->aid = pte->aid; switch (addr->aid) { case AID_INET: @@ -113,7 +113,7 @@ pt_fill(struct bgpd_addr *prefix, int prefixlen) switch (prefix->aid) { case AID_INET: - bzero(&pte4, sizeof(pte4)); + memset(&pte4, 0, sizeof(pte4)); pte4.aid = prefix->aid; if (prefixlen > 32) fatalx("pt_fill: bad IPv4 prefixlen"); @@ -121,7 +121,7 @@ pt_fill(struct bgpd_addr *prefix, int prefixlen) pte4.prefixlen = prefixlen; return ((struct pt_entry *)&pte4); case AID_INET6: - bzero(&pte6, sizeof(pte6)); + memset(&pte6, 0, sizeof(pte6)); pte6.aid = prefix->aid; if (prefixlen > 128) fatalx("pt_fill: bad IPv6 prefixlen"); @@ -129,7 +129,7 @@ pt_fill(struct bgpd_addr *prefix, int prefixlen) pte6.prefixlen = prefixlen; return ((struct pt_entry *)&pte6); case AID_VPN_IPv4: - bzero(&pte_vpn4, sizeof(pte_vpn4)); + memset(&pte_vpn4, 0, sizeof(pte_vpn4)); pte_vpn4.aid = prefix->aid; if (prefixlen > 32) fatalx("pt_fill: bad IPv4 prefixlen"); diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 6fd8180c61c..2a0758f0ae5 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.145 2022/07/11 17:08:21 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.146 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker @@ -392,7 +392,7 @@ up_generate_default(struct filter_head *rules, struct rde_peer *peer, */ /* rde_apply_set(asp, peerself, peerself, set, af); */ - bzero(&addr, sizeof(addr)); + memset(&addr, 0, sizeof(addr)); addr.aid = aid; p = prefix_adjout_lookup(peer, &addr, 0); @@ -898,7 +898,7 @@ up_dump_mp_unreach(u_char *buf, int len, struct rde_peer *peer, uint8_t aid) memcpy(attrbuf + 2, &attr_len, sizeof(attr_len)); /* write length fields */ - bzero(buf, sizeof(uint16_t)); /* withdrawn routes len */ + memset(buf, 0, sizeof(uint16_t)); /* withdrawn routes len */ attr_len = htons(wpos - 4); memcpy(buf + 2, &attr_len, sizeof(attr_len)); @@ -934,7 +934,7 @@ up_dump_attrnlri(u_char *buf, int len, struct rde_peer *peer) * an invalid bgp update. */ done: - bzero(buf, 2); + memset(buf, 0, 2); return (2); } @@ -998,7 +998,7 @@ up_generate_mp_reach(u_char *buf, int len, struct rde_peer *peer, tmp = htons(tmp); memcpy(attrbuf, &tmp, sizeof(tmp)); attrbuf[3] = sizeof(uint64_t) + sizeof(struct in_addr); - bzero(attrbuf + 4, sizeof(uint64_t)); + memset(attrbuf + 4, 0, sizeof(uint64_t)); attrbuf[16] = 0; /* Reserved must be 0 */ /* write nexthop */ @@ -1016,7 +1016,7 @@ up_generate_mp_reach(u_char *buf, int len, struct rde_peer *peer, tmp = htons(tmp); memcpy(attrbuf, &tmp, sizeof(tmp)); attrbuf[3] = sizeof(uint64_t) + sizeof(struct in6_addr); - bzero(attrbuf + 4, sizeof(uint64_t)); + memset(attrbuf + 4, 0, sizeof(uint64_t)); attrbuf[28] = 0; /* Reserved must be 0 */ /* write nexthop */ @@ -1080,7 +1080,7 @@ up_dump_mp_reach(u_char *buf, int len, struct rde_peer *peer, uint8_t aid) wpos += r; /* write length fields */ - bzero(buf, sizeof(uint16_t)); /* withdrawn routes len */ + memset(buf, 0, sizeof(uint16_t)); /* withdrawn routes len */ attr_len = htons(wpos - 4); memcpy(buf + 2, &attr_len, sizeof(attr_len)); diff --git a/usr.sbin/bgpd/rtr.c b/usr.sbin/bgpd/rtr.c index ebfd88a467d..13c5111230b 100644 --- a/usr.sbin/bgpd/rtr.c +++ b/usr.sbin/bgpd/rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtr.c,v 1.5 2022/01/20 18:06:20 claudio Exp $ */ +/* $OpenBSD: rtr.c,v 1.6 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -158,7 +158,7 @@ rtr_main(int debug, int verbose) if (timeout == -1) fatalx("roa-set expire timer no longer runnning"); - bzero(pfd, sizeof(struct pollfd) * pfd_elms); + memset(pfd, 0, sizeof(struct pollfd) * pfd_elms); set_pollfd(&pfd[PFD_PIPE_MAIN], ibuf_main); set_pollfd(&pfd[PFD_PIPE_RDE], ibuf_rde); diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index f80b6f79b14..40a9a70d8a1 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.432 2022/07/28 13:11:51 deraadt Exp $ */ +/* $OpenBSD: session.c,v 1.433 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -336,7 +336,7 @@ session_main(int debug, int verbose) pfd_elms = new_cnt; } - bzero(pfd, sizeof(struct pollfd) * pfd_elms); + memset(pfd, 0, sizeof(struct pollfd) * pfd_elms); set_pollfd(&pfd[PFD_PIPE_MAIN], ibuf_main); set_pollfd(&pfd[PFD_PIPE_ROUTE], ibuf_rde); @@ -892,7 +892,7 @@ change_state(struct peer *peer, enum session_state state, free(peer->rbuf); peer->rbuf = NULL; peer->rpending = 0; - bzero(&peer->capa.peer, sizeof(peer->capa.peer)); + memset(&peer->capa.peer, 0, sizeof(peer->capa.peer)); if (!peer->template) imsg_compose(ibuf_main, IMSG_PFKEY_RELOAD, peer->conf.id, 0, -1, NULL, 0); @@ -938,7 +938,7 @@ change_state(struct peer *peer, enum session_state state, timer_stop(&peer->timers, Timer_IdleHoldReset); session_close_connection(peer); msgbuf_clear(&peer->wbuf); - bzero(&peer->capa.peer, sizeof(peer->capa.peer)); + memset(&peer->capa.peer, 0, sizeof(peer->capa.peer)); } break; case STATE_ACTIVE: @@ -1300,7 +1300,7 @@ session_tcp_established(struct peer *peer) void session_capa_ann_none(struct peer *peer) { - bzero(&peer->capa.ann, sizeof(peer->capa.ann)); + memset(&peer->capa.ann, 0, sizeof(peer->capa.ann)); } int @@ -3296,7 +3296,7 @@ la_cmp(struct listen_addr *a, struct listen_addr *b) case AF_INET6: in6_a = (struct sockaddr_in6 *)&a->sa; in6_b = (struct sockaddr_in6 *)&b->sa; - if (bcmp(&in6_a->sin6_addr, &in6_b->sin6_addr, + if (memcmp(&in6_a->sin6_addr, &in6_b->sin6_addr, sizeof(struct in6_addr))) return (1); if (in6_a->sin6_port != in6_b->sin6_port) @@ -3457,7 +3457,7 @@ session_match_mask(struct peer *p, struct bgpd_addr *a) void session_down(struct peer *peer) { - bzero(&peer->capa.neg, sizeof(peer->capa.neg)); + memset(&peer->capa.neg, 0, sizeof(peer->capa.neg)); peer->stats.last_updown = getmonotime(); /* * session_down is called in the exit code path so check diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c index 30aef0a83d0..efa1ad3595d 100644 --- a/usr.sbin/bgpd/util.c +++ b/usr.sbin/bgpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.70 2022/07/19 13:03:09 claudio Exp $ */ +/* $OpenBSD: util.c,v 1.71 2022/08/17 15:15:26 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -60,7 +60,7 @@ log_in6addr(const struct in6_addr *addr) { struct sockaddr_in6 sa_in6; - bzero(&sa_in6, sizeof(sa_in6)); + memset(&sa_in6, 0, sizeof(sa_in6)); sa_in6.sin6_family = AF_INET6; memcpy(&sa_in6.sin6_addr, addr, sizeof(sa_in6.sin6_addr)); @@ -531,7 +531,7 @@ nlri_get_prefix(u_char *p, uint16_t len, struct bgpd_addr *prefix, pfxlen = *p++; len--; - bzero(prefix, sizeof(struct bgpd_addr)); + memset(prefix, 0, sizeof(struct bgpd_addr)); prefix->aid = AID_INET; *prefixlen = pfxlen; @@ -557,7 +557,7 @@ nlri_get_prefix6(u_char *p, uint16_t len, struct bgpd_addr *prefix, pfxlen = *p++; len--; - bzero(prefix, sizeof(struct bgpd_addr)); + memset(prefix, 0, sizeof(struct bgpd_addr)); prefix->aid = AID_INET6; *prefixlen = pfxlen; @@ -585,7 +585,7 @@ nlri_get_vpn4(u_char *p, uint16_t len, struct bgpd_addr *prefix, p += 1; plen = 1; - bzero(prefix, sizeof(struct bgpd_addr)); + memset(prefix, 0, sizeof(struct bgpd_addr)); /* label stack */ do { @@ -796,7 +796,7 @@ inet6applymask(struct in6_addr *dest, const struct in6_addr *src, int prefixlen) struct in6_addr mask; int i; - bzero(&mask, sizeof(mask)); + memset(&mask, 0, sizeof(mask)); for (i = 0; i < prefixlen / 8; i++) mask.s6_addr[i] = 0xff; i = prefixlen % 8; @@ -898,7 +898,7 @@ addr2sa(const struct bgpd_addr *addr, uint16_t port, socklen_t *len) if (addr == NULL || addr->aid == AID_UNSPEC) return (NULL); - bzero(&ss, sizeof(ss)); + memset(&ss, 0, sizeof(ss)); switch (addr->aid) { case AID_INET: case AID_VPN_IPv4: @@ -927,7 +927,7 @@ sa2addr(struct sockaddr *sa, struct bgpd_addr *addr, uint16_t *port) struct sockaddr_in *sa_in = (struct sockaddr_in *)sa; struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)sa; - bzero(addr, sizeof(*addr)); + memset(addr, 0, sizeof(*addr)); switch (sa->sa_family) { case AF_INET: addr->aid = AID_INET; -- 2.20.1