The memory regions passed to memcpy() can not overlap so no need for memmove().
OK tb@ deraadt@
-/* $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 <henning@openbsd.org>
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);
-/* $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 <henning@openbsd.org>
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) {
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;
-/* $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 <henning@openbsd.org>
p[0] = '\0';
}
- bzero(h, sizeof(*h));
+ memset(h, 0, sizeof(*h));
if (host_ip(ps, h, len) == 0) {
free(ps);
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;
-/* $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 <henning@openbsd.org>
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));
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)) {
-/* $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 <claudio@openbsd.org>
}
krt = xkrt;
krt_size = rtableid + 1;
- bzero((char *)krt + oldsize,
+ memset((char *)krt + oldsize, 0,
krt_size * sizeof(struct ktable *) - oldsize);
}
/* 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);
/* 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) {
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),
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) {
{
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;
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);
{
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;
{
static struct kroute_full kf;
- bzero(&kf, sizeof(kf));
+ memset(&kf, 0, sizeof(kf));
kf.prefix.aid = AID_INET6;
kf.prefix.v6 = kr6->prefix;
{
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));
{
struct kif s;
- bzero(&s, sizeof(s));
+ memset(&s, 0, sizeof(s));
s.ifindex = ifindex;
return (RB_FIND(kif_tree, &kit, &s));
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;
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;
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__
/* 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__
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);
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;
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;
}
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;
-/* $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 <claudio@openbsd.org>
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
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
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
-/* $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 <henning@openbsd.org>
;
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 */
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;
;
filter_match_h : /* empty */ {
- bzero(&$$, sizeof($$));
+ memset(&$$, 0, sizeof($$));
}
| {
- bzero(&fmopts, sizeof(fmopts));
+ memset(&fmopts, 0, sizeof(fmopts));
}
filter_match {
memcpy(&$$, &fmopts, sizeof($$));
}
;
-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;
| PREFIXLEN unaryop NUMBER {
int min, max;
- bzero(&$$, sizeof($$));
+ memset(&$$, 0, sizeof($$));
if ($3 < 0 || $3 > 128) {
yyerror("prefixlen must be >= 0 and <= 128");
YYERROR;
$$.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;
-/* $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 <henning@openbsd.org>
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;
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;
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;
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;
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;
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;
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;
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;
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);
}
break;
}
- bzero(&dmask, sizeof(dmask));
+ memset(&dmask, 0, sizeof(dmask));
switch (dst->aid) {
case AID_INET:
dmask.ss_len = sizeof(struct sockaddr_in);
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;
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);
}
-/* $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 <djm@openbsd.org>
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;
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));
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;
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;
-/* $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 <henning@openbsd.org>
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);
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);
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;
}
}
- 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 */
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);
/*
if (nhlen > len)
return (-1);
- bzero(&nexthop, sizeof(nexthop));
+ memset(&nexthop, 0, sizeof(nexthop));
nexthop.aid = aid;
switch (aid) {
case AID_INET6:
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) {
/* 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,
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;
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");
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,
-/* $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 <claudio@openbsd.org>
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;
-/* $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 <claudio@openbsd.org>
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:
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");
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");
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");
-/* $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 <claudio@openbsd.org>
*/
/* 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);
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));
* an invalid bgp update.
*/
done:
- bzero(buf, 2);
+ memset(buf, 0, 2);
return (2);
}
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 */
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 */
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));
-/* $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 <claudio@openbsd.org>
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);
-/* $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 <henning@openbsd.org>
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);
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);
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:
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
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)
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
-/* $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 <claudio@openbsd.org>
{
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));
pfxlen = *p++;
len--;
- bzero(prefix, sizeof(struct bgpd_addr));
+ memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_INET;
*prefixlen = pfxlen;
pfxlen = *p++;
len--;
- bzero(prefix, sizeof(struct bgpd_addr));
+ memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_INET6;
*prefixlen = pfxlen;
p += 1;
plen = 1;
- bzero(prefix, sizeof(struct bgpd_addr));
+ memset(prefix, 0, sizeof(struct bgpd_addr));
/* label stack */
do {
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;
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:
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;