From: tedu Date: Thu, 9 Jan 2014 06:29:05 +0000 (+0000) Subject: bzero/bcmp -> memset/memcmp. ok matthew X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f8575965c051a8860b17537a7a6aac2871d39ab5;p=openbsd bzero/bcmp -> memset/memcmp. ok matthew --- diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 937e147fe73..b556c89e0fa 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.114 2013/12/31 03:24:44 tedu Exp $ */ +/* $OpenBSD: if_ether.c,v 1.115 2014/01/09 06:29:05 tedu Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -309,7 +309,7 @@ arprequest(struct ifnet *ifp, u_int32_t *sip, u_int32_t *tip, u_int8_t *enaddr) MH_ALIGN(m, sizeof(*ea)); ea = mtod(m, struct ether_arp *); eh = (struct ether_header *)sa.sa_data; - bzero((caddr_t)ea, sizeof (*ea)); + memset(ea, 0, sizeof(*ea)); memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost)); eh->ether_type = htons(ETHERTYPE_ARP); /* if_output will not swap */ ea->arp_hrd = htons(ARPHRD_ETHER); @@ -613,10 +613,10 @@ in_arpinput(struct mbuf *m) enaddr = ac->ac_enaddr; myaddr = ifatoia(ifa)->ia_addr.sin_addr; - if (!bcmp((caddr_t)ea->arp_sha, enaddr, sizeof (ea->arp_sha))) + if (!memcmp(ea->arp_sha, enaddr, sizeof(ea->arp_sha))) goto out; /* it's from me, ignore it. */ if (ETHER_IS_MULTICAST(&ea->arp_sha[0])) - if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr, + if (!memcmp(ea->arp_sha, etherbroadcastaddr, sizeof (ea->arp_sha))) { inet_ntop(AF_INET, &isaddr, addr, sizeof(addr)); log(LOG_ERR, "arp: ether address is broadcast for " @@ -635,7 +635,7 @@ in_arpinput(struct mbuf *m) rtable_l2(m->m_pkthdr.rdomain)); if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) { if (sdl->sdl_alen) { - if (bcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) { + if (memcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) { if (rt->rt_flags & RTF_PERMANENT_ARP) { inet_ntop(AF_INET, &isaddr, addr, sizeof(addr)); log(LOG_WARNING, @@ -780,7 +780,7 @@ arptfree(struct llinfo_arp *la) rt->rt_flags &= ~RTF_REJECT; return; } - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_NETMASK] = rt_mask(rt); @@ -799,7 +799,7 @@ arplookup(u_int32_t addr, int create, int proxy, u_int tableid) struct rtentry *rt; struct sockaddr_inarp sin; - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = addr; @@ -815,7 +815,7 @@ arplookup(u_int32_t addr, int create, int proxy, u_int tableid) (rt->rt_flags & RTF_CLONED) != 0) { struct rt_addrinfo info; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_info[RTAX_NETMASK] = rt_mask(rt); @@ -847,7 +847,7 @@ arpproxy(struct in_addr in, u_int rdomain) if (ifp->if_rdomain != rdomain) continue; - if (!bcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway), + if (!memcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway), LLADDR((struct sockaddr_dl *)ifp->if_lladdr->ifa_addr), ETHER_ADDR_LEN)) { found = 1; @@ -944,7 +944,7 @@ in_revarpinput(struct mbuf *m) goto out; if (revarp_finished) goto wake; - if (bcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr, + if (memcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr, sizeof(ar->arp_tha))) goto out; memcpy(&revarp_srvip, ar->arp_spa, sizeof(revarp_srvip)); @@ -978,7 +978,7 @@ revarprequest(struct ifnet *ifp) MH_ALIGN(m, sizeof(*ea)); ea = mtod(m, struct ether_arp *); eh = (struct ether_header *)sa.sa_data; - bzero((caddr_t)ea, sizeof(*ea)); + memset(ea, 0, sizeof(*ea)); memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost)); eh->ether_type = htons(ETHERTYPE_REVARP); ea->arp_hrd = htons(ARPHRD_ETHER); diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 10c8b0703a2..33acb83e9a8 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.52 2013/11/21 16:34:33 mikeb Exp $ */ +/* $OpenBSD: if_ether.h,v 1.53 2014/01/09 06:29:05 tedu Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -245,9 +245,9 @@ struct ether_multistep { /* struct ether_multi *enm; */ \ do { \ for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \ - (enm) != NULL && \ - (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \ - bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \ + (enm) != NULL && \ + (memcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||\ + memcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \ (enm) = LIST_NEXT((enm), enm_list)); \ } while (/* CONSTCOND */ 0) diff --git a/sys/netinet/ip_ah.c b/sys/netinet/ip_ah.c index b82bd210dec..64f5f198d72 100644 --- a/sys/netinet/ip_ah.c +++ b/sys/netinet/ip_ah.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ah.c,v 1.107 2013/06/11 18:15:53 deraadt Exp $ */ +/* $OpenBSD: ip_ah.c,v 1.108 2014/01/09 06:29:05 tedu Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -167,13 +167,13 @@ ah_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii) bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); /* Initialize crypto session. */ - bzero(&cria, sizeof(cria)); + memset(&cria, 0, sizeof(cria)); cria.cri_alg = tdbp->tdb_authalgxform->type; cria.cri_klen = ii->ii_authkeylen * 8; cria.cri_key = ii->ii_authkey; if ((tdbp->tdb_wnd > 0) && (tdbp->tdb_flags & TDBF_ESN)) { - bzero(&crin, sizeof(crin)); + memset(&crin, 0, sizeof(crin)); crin.cri_alg = CRYPTO_ESN; cria.cri_next = &crin; } @@ -678,7 +678,7 @@ ah_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) if (tdbi->proto == tdb->tdb_sproto && tdbi->spi == tdb->tdb_spi && tdbi->rdomain == tdb->tdb_rdomain && - !bcmp(&tdbi->dst, &tdb->tdb_dst, + !memcmp(&tdbi->dst, &tdb->tdb_dst, sizeof(union sockaddr_union))) break; } @@ -1009,7 +1009,7 @@ ah_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, if (encif->if_bpf) { struct enchdr hdr; - bzero (&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.af = tdb->tdb_dst.sa.sa_family; hdr.spi = tdb->tdb_spi; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index f0109971034..20cab9b69c0 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.217 2013/11/28 09:36:37 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.218 2014/01/09 06:29:06 tedu Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -281,7 +281,7 @@ carp_hmac_prepare_ctx(struct carp_vhost_entry *vhe, u_int8_t ctx) #endif /* INET6 */ /* compute ipad from key */ - bzero(vhe->vhe_pad, sizeof(vhe->vhe_pad)); + memset(vhe->vhe_pad, 0, sizeof(vhe->vhe_pad)); bcopy(sc->sc_key, vhe->vhe_pad, sizeof(sc->sc_key)); for (i = 0; i < sizeof(vhe->vhe_pad); i++) vhe->vhe_pad[i] ^= 0x36; @@ -302,7 +302,7 @@ carp_hmac_prepare_ctx(struct carp_vhost_entry *vhe, u_int8_t ctx) /* the rest of the precomputation */ if (!sc->sc_realmac && vhe->vhe_leader && - bcmp(sc->sc_ac.ac_enaddr, vhe->vhe_enaddr, ETHER_ADDR_LEN) != 0) + memcmp(sc->sc_ac.ac_enaddr, vhe->vhe_enaddr, ETHER_ADDR_LEN) != 0) SHA1Update(&vhe->vhe_sha1[ctx], sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN); @@ -419,7 +419,7 @@ carp_setroute(struct carp_softc *sc, int cmd) const char *label; /* Remove the existing host route, if any */ - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = ifa->ifa_addr; info.rti_flags = RTF_HOST; error = rtrequest1(RTM_DELETE, &info, RTP_CONNECTED, @@ -445,7 +445,7 @@ carp_setroute(struct carp_softc *sc, int cmd) nr_ourif = (rt && rt->rt_ifp == &sc->sc_if); /* Restore the route label */ - bzero(&sa_rl, sizeof(sa_rl)); + memset(&sa_rl, 0, sizeof(sa_rl)); if (rt && rt->rt_labelid) { sa_rl.sr_len = sizeof(sa_rl); sa_rl.sr_family = AF_UNSPEC; @@ -460,7 +460,7 @@ carp_setroute(struct carp_softc *sc, int cmd) if (hr_otherif) { ifa->ifa_rtrequest = NULL; ifa->ifa_flags &= ~RTF_CLONING; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = ifa->ifa_addr; info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; info.rti_flags = RTF_UP | RTF_HOST; @@ -474,7 +474,7 @@ carp_setroute(struct carp_softc *sc, int cmd) if (!hr_otherif || nr_ourif || !rt) { if (nr_ourif && !(rt->rt_flags & RTF_CLONING)) { - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = &sa; info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; error = rtrequest1(RTM_DELETE, @@ -487,7 +487,7 @@ carp_setroute(struct carp_softc *sc, int cmd) ifa->ifa_rtrequest = arp_rtrequest; ifa->ifa_flags |= RTF_CLONING; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = &sa; info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; @@ -727,7 +727,7 @@ carp_proto_input_c(struct mbuf *m, struct carp_header *ch, int ismulti, return; } - if (!bcmp(&vhe->vhe_replay_cookie, ch->carp_counter, + if (!memcmp(&vhe->vhe_replay_cookie, ch->carp_counter, sizeof(ch->carp_counter))) { /* Do not log duplicates from non simplex interfaces */ if (sc->sc_carpdev->if_flags & IFF_SIMPLEX) { @@ -1161,7 +1161,7 @@ carp_send_ad(void *v) ip->ip_p = IPPROTO_CARP; ip->ip_sum = 0; - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); sa.sa_family = AF_INET; ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); if (ifa == NULL) @@ -1243,17 +1243,17 @@ carp_send_ad(void *v) MH_ALIGN(m, m->m_len); m->m_flags |= M_MCAST; ip6 = mtod(m, struct ip6_hdr *); - bzero(ip6, sizeof(*ip6)); + memset(ip6, 0, sizeof(*ip6)); ip6->ip6_vfc |= IPV6_VERSION; ip6->ip6_hlim = CARP_DFLTTL; ip6->ip6_nxt = IPPROTO_CARP; /* set the source address */ - bzero(&sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); sa.sa_family = AF_INET6; ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); if (ifa == NULL) /* This should never happen with IPv6 */ - bzero(&ip6->ip6_src, sizeof(struct in6_addr)); + memset(&ip6->ip6_src, 0, sizeof(struct in6_addr)); else bcopy(ifatoia6(ifa)->ia_addr.sin6_addr.s6_addr, &ip6->ip6_src, sizeof(struct in6_addr)); @@ -1517,13 +1517,14 @@ carp_ourether(void *v, u_int8_t *ena) if (vh->sc_balancing == CARP_BAL_ARP) { LIST_FOREACH(vhe, &vh->carp_vhosts, vhost_entries) if (vhe->state == MASTER && - !bcmp(ena, vhe->vhe_enaddr, ETHER_ADDR_LEN)) + !memcmp(ena, vhe->vhe_enaddr, + ETHER_ADDR_LEN)) return (&vh->sc_if); } else { vhe = LIST_FIRST(&vh->carp_vhosts); if ((vhe->state == MASTER || vh->sc_balancing >= CARP_BAL_IP) && - !bcmp(ena, vh->sc_ac.ac_enaddr, ETHER_ADDR_LEN)) + !memcmp(ena, vh->sc_ac.ac_enaddr, ETHER_ADDR_LEN)) return (&vh->sc_if); } } @@ -1554,7 +1555,7 @@ carp_our_mcastaddr(struct ifnet *ifp, u_int8_t *d_enaddr) if (sc->sc_balancing != CARP_BAL_IP) return (0); - return(!bcmp(sc->sc_ac.ac_enaddr, d_enaddr, ETHER_ADDR_LEN)); + return (!memcmp(sc->sc_ac.ac_enaddr, d_enaddr, ETHER_ADDR_LEN)); } @@ -1701,7 +1702,7 @@ carp_setrun(struct carp_vhost_entry *vhe, sa_family_t af) return; } - if (bcmp(((struct arpcom *)sc->sc_carpdev)->ac_enaddr, + if (memcmp(((struct arpcom *)sc->sc_carpdev)->ac_enaddr, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN) == 0) sc->sc_realmac = 1; else @@ -1916,7 +1917,7 @@ carp_set_vhe_enaddr(struct carp_vhost_entry *vhe) vhe->vhe_sdl.sdl_alen = ETHER_ADDR_LEN; bcopy(vhe->vhe_enaddr, vhe->vhe_sdl.sdl_data, ETHER_ADDR_LEN); } else - bzero(vhe->vhe_enaddr, ETHER_ADDR_LEN); + memset(vhe->vhe_enaddr, 0, ETHER_ADDR_LEN); } void @@ -1933,7 +1934,7 @@ carp_set_enaddr(struct carp_softc *sc) * Use the carp lladdr if the running one isn't manually set. * Only compare static parts of the lladdr. */ - if ((bcmp(sc->sc_ac.ac_enaddr + 1, vhe->vhe_enaddr + 1, + if ((memcmp(sc->sc_ac.ac_enaddr + 1, vhe->vhe_enaddr + 1, ETHER_ADDR_LEN - 2) == 0) || (!sc->sc_ac.ac_enaddr[0] && !sc->sc_ac.ac_enaddr[1] && !sc->sc_ac.ac_enaddr[2] && !sc->sc_ac.ac_enaddr[3] && @@ -1941,7 +1942,7 @@ carp_set_enaddr(struct carp_softc *sc) bcopy(vhe->vhe_enaddr, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN); /* Make sure the enaddr has changed before further twiddling. */ - if (bcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) { + if (memcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) { bcopy(sc->sc_ac.ac_enaddr, LLADDR(sc->sc_if.if_sadl), ETHER_ADDR_LEN); bcopy(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN); @@ -1992,7 +1993,7 @@ carp_addr_updated(void *v) u_int16_t maxmem = sc->sc_imo.imo_max_memberships; - bzero(&sc->sc_imo, sizeof(sc->sc_imo)); + memset(&sc->sc_imo, 0, sizeof(sc->sc_imo)); sc->sc_imo.imo_membership = imm; sc->sc_imo.imo_max_memberships = maxmem; @@ -2160,7 +2161,7 @@ carp_join_multicast6(struct carp_softc *sc) int error; /* Join IPv6 CARP multicast group */ - bzero(&addr6, sizeof(addr6)); + memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; addr6.sin6_len = sizeof(addr6); addr6.sin6_addr.s6_addr16[0] = htons(0xff02); @@ -2171,7 +2172,7 @@ carp_join_multicast6(struct carp_softc *sc) return (error); } /* join solicited multicast address */ - bzero(&addr6.sin6_addr, sizeof(addr6.sin6_addr)); + memset(&addr6.sin6_addr, 0, sizeof(addr6.sin6_addr)); addr6.sin6_addr.s6_addr16[0] = htons(0xff02); addr6.sin6_addr.s6_addr16[1] = htons(sc->sc_if.if_index); addr6.sin6_addr.s6_addr32[1] = 0; @@ -2301,7 +2302,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) sc->sc_advbase = carpr.carpr_advbase; error--; } - if (bcmp(sc->sc_advskews, carpr.carpr_advskews, + if (memcmp(sc->sc_advskews, carpr.carpr_advskews, sizeof(sc->sc_advskews))) { i = 0; LIST_FOREACH(vhe, &sc->carp_vhosts, vhost_entries) @@ -2329,7 +2330,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) break; case SIOCGVH: - bzero(&carpr, sizeof(carpr)); + memset(&carpr, 0, sizeof(carpr)); if (sc->sc_carpdev != NULL) strlcpy(carpr.carpr_carpdev, sc->sc_carpdev->if_xname, IFNAMSIZ); @@ -2368,7 +2369,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) error = ENOTTY; } - if (bcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) + if (memcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) carp_set_enaddr(sc); return (error); } @@ -2407,10 +2408,10 @@ carp_vhids_ioctl(struct carp_softc *sc, struct carpreq *carpr) u_int8_t taken_vhids[256]; if (carpr->carpr_vhids[0] == 0 || - !bcmp(sc->sc_vhids, carpr->carpr_vhids, sizeof(sc->sc_vhids))) + !memcmp(sc->sc_vhids, carpr->carpr_vhids, sizeof(sc->sc_vhids))) return (0); - bzero(taken_vhids, sizeof(taken_vhids)); + memset(taken_vhids, 0, sizeof(taken_vhids)); for (i = 0; carpr->carpr_vhids[i]; i++) { if (taken_vhids[carpr->carpr_vhids[i]]) return (EINVAL); @@ -2435,7 +2436,7 @@ carp_vhids_ioctl(struct carp_softc *sc, struct carpreq *carpr) /* destroy all */ carp_del_all_timeouts(sc); carp_destroy_vhosts(sc); - bzero(sc->sc_vhids, sizeof(sc->sc_vhids)); + memset(sc->sc_vhids, 0, sizeof(sc->sc_vhids)); /* sort vhosts list by vhid */ for (j = 1; j <= 255; j++) { diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 2296197ecbc..5365618f591 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.15 2013/12/20 02:04:08 krw Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.16 2014/01/09 06:29:06 tedu Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -233,7 +233,7 @@ divert_packet(struct mbuf *m, int dir) break; } - bzero(&addr, sizeof(addr)); + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_len = sizeof(addr); diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index a07d88142d8..9df5825cf31 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.122 2013/04/11 12:06:25 mpi Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.123 2014/01/09 06:29:06 tedu Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -255,7 +255,7 @@ esp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii) M_WAITOK); bcopy(ii->ii_enckey, tdbp->tdb_emxkey, tdbp->tdb_emxkeylen); - bzero(&crie, sizeof(crie)); + memset(&crie, 0, sizeof(crie)); crie.cri_alg = tdbp->tdb_encalgxform->type; @@ -276,12 +276,12 @@ esp_init(struct tdb *tdbp, struct xformsw *xsp, struct ipsecinit *ii) M_WAITOK); bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen); - bzero(&cria, sizeof(cria)); + memset(&cria, 0, sizeof(cria)); cria.cri_alg = tdbp->tdb_authalgxform->type; if ((tdbp->tdb_wnd > 0) && (tdbp->tdb_flags & TDBF_ESN)) { - bzero(&crin, sizeof(crin)); + memset(&crin, 0, sizeof(crin)); crin.cri_alg = CRYPTO_ESN; cria.cri_next = &crin; } @@ -429,7 +429,7 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) tdbi = (struct tdb_ident *) (mtag + 1); if (tdbi->proto == tdb->tdb_sproto && tdbi->spi == tdb->tdb_spi && - tdbi->rdomain == tdb->tdb_rdomain && !bcmp(&tdbi->dst, + tdbi->rdomain == tdb->tdb_rdomain && !memcmp(&tdbi->dst, &tdb->tdb_dst, sizeof(union sockaddr_union))) break; } @@ -793,7 +793,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, if (encif->if_bpf) { struct enchdr hdr; - bzero (&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.af = tdb->tdb_dst.sa.sa_family; hdr.spi = tdb->tdb_spi; @@ -1161,7 +1161,7 @@ checkreplaywindow(struct tdb *tdb, u_int32_t seq, u_int32_t *seqhigh, if (seq > tl) { if (commit) { if (seq - tl > window) - bzero(tdb->tdb_seen, + memset(tdb->tdb_seen, 0, sizeof(tdb->tdb_seen)); else { int i = (tl % TDB_REPLAYMAX) / 32; @@ -1213,7 +1213,7 @@ checkreplaywindow(struct tdb *tdb, u_int32_t seq, u_int32_t *seqhigh, return (1); if (commit) { if (seq - tl > window) - bzero(tdb->tdb_seen, sizeof(tdb->tdb_seen)); + memset(tdb->tdb_seen, 0, sizeof(tdb->tdb_seen)); else { int i = (tl % TDB_REPLAYMAX) / 32; diff --git a/sys/netinet/ip_ether.c b/sys/netinet/ip_ether.c index d7b94be5692..c8e745fbd83 100644 --- a/sys/netinet/ip_ether.c +++ b/sys/netinet/ip_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ether.c,v 1.64 2013/12/31 03:24:44 tedu Exp $ */ +/* $OpenBSD: ip_ether.c,v 1.65 2014/01/09 06:29:06 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (kermit@adk.gr) * @@ -252,8 +252,8 @@ etherip_decap(struct mbuf *m, int iphlen) /* Reset the flags based on the inner packet */ m->m_flags &= ~(M_BCAST|M_MCAST|M_AUTH|M_CONF); if (eh.ether_dhost[0] & 1) { - if (bcmp((caddr_t) etherbroadcastaddr, - (caddr_t)eh.ether_dhost, sizeof(etherbroadcastaddr)) == 0) + if (memcmp(etherbroadcastaddr, eh.ether_dhost, + sizeof(etherbroadcastaddr)) == 0) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; @@ -374,8 +374,8 @@ etherip_getgif(struct mbuf *m) u_int8_t v; /* Copy the addresses for use later. */ - bzero(&ssrc, sizeof(ssrc)); - bzero(&sdst, sizeof(sdst)); + memset(&ssrc, 0, sizeof(ssrc)); + memset(&sdst, 0, sizeof(sdst)); v = *mtod(m, u_int8_t *); switch (v >> 4) { @@ -417,8 +417,8 @@ etherip_getgif(struct mbuf *m) !(sc->gif_if.if_flags & (IFF_UP|IFF_RUNNING))) continue; - if (!bcmp(sc->gif_psrc, &sdst, sc->gif_psrc->sa_len) && - !bcmp(sc->gif_pdst, &ssrc, sc->gif_pdst->sa_len)) + if (!memcmp(sc->gif_psrc, &sdst, sc->gif_psrc->sa_len) && + !memcmp(sc->gif_pdst, &ssrc, sc->gif_pdst->sa_len)) break; } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index a04f979a180..fa601b885a5 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.112 2013/12/31 03:24:44 tedu Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.113 2014/01/09 06:29:06 tedu Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -473,7 +473,7 @@ icmp_input(struct mbuf *m, ...) if (icmpprintfs) printf("deliver to protocol %d\n", icp->icmp_ip.ip_p); #endif - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = icp->icmp_ip.ip_dst; @@ -535,7 +535,7 @@ icmp_input(struct mbuf *m, ...) * We are not able to respond with all ones broadcast * unless we receive it over a point-to-point interface. */ - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_len = sizeof(struct sockaddr_in); if (ip->ip_dst.s_addr == INADDR_BROADCAST || @@ -604,9 +604,9 @@ reflect: * listening on a raw socket (e.g. the routing * daemon for use in updating its tables). */ - bzero(&sdst, sizeof(sdst)); - bzero(&sgw, sizeof(sgw)); - bzero(&ssrc, sizeof(ssrc)); + memset(&sdst, 0, sizeof(sdst)); + memset(&sgw, 0, sizeof(sgw)); + memset(&ssrc, 0, sizeof(ssrc)); sdst.sin_family = sgw.sin_family = ssrc.sin_family = AF_INET; sdst.sin_len = sgw.sin_len = ssrc.sin_len = sizeof(sdst); memcpy(&sdst.sin_addr, &icp->icmp_ip.ip_dst, sizeof(sdst)); @@ -723,7 +723,7 @@ icmp_reflect(struct mbuf *m, struct mbuf **op, struct in_ifaddr *ia) struct sockaddr_in *dst; struct route ro; - bzero((caddr_t) &ro, sizeof(ro)); + memset(&ro, 0, sizeof(ro)); ro.ro_tableid = m->m_pkthdr.rdomain; dst = satosin(&ro.ro_dst); dst->sin_family = AF_INET; @@ -915,7 +915,7 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) struct rtentry *rt; int error; - bzero(&ro, sizeof(ro)); + memset(&ro, 0, sizeof(ro)); ro.ro_tableid = rtableid; sin = satosin(&ro.ro_dst); sin->sin_family = AF_INET; @@ -937,7 +937,7 @@ icmp_mtudisc_clone(struct in_addr dst, u_int rtableid) struct rtentry *nrt; struct rt_addrinfo info; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = sintosa(sin); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC; @@ -1032,7 +1032,7 @@ icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r) struct sockaddr_in sa; struct rt_addrinfo info; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_NETMASK] = rt_mask(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; @@ -1079,7 +1079,7 @@ icmp_redirect_timeout(struct rtentry *rt, struct rttimer *r) (RTF_DYNAMIC | RTF_HOST)) { struct rt_addrinfo info; - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_NETMASK] = rt_mask(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; @@ -1123,7 +1123,7 @@ icmp_do_exthdr(struct mbuf *m, u_int16_t class, u_int8_t ctype, void *buf, off = max(off, ICMP_EXT_OFFSET); icp->icmp_length = off / sizeof(u_int32_t); - bzero(&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.ieh.ieh_version = ICMP_EXT_HDR_VERSION; hdr.ieo.ieo_length = htons(sizeof(struct icmp_ext_obj_hdr) + len); hdr.ieo.ieo_cnum = class; diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index cb17cf8d5e2..5b46a120a64 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.223 2013/12/31 03:24:44 tedu Exp $ */ +/* $OpenBSD: ip_input.c,v 1.224 2014/01/09 06:29:06 tedu Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -177,7 +177,7 @@ ip_init(void) rt_timer_queue_create(ip_mtudisc_timeout); /* Fill in list of ports not to allocate dynamically. */ - bzero((void *)&baddynamicports, sizeof(baddynamicports)); + memset(&baddynamicports, 0, sizeof(baddynamicports)); for (i = 0; defbaddynamicports_tcp[i] != 0; i++) DP_SET(baddynamicports.tcp, defbaddynamicports_tcp[i]); for (i = 0; defbaddynamicports_udp[i] != 0; i++) @@ -669,7 +669,7 @@ in_ouraddr(struct in_addr ina, struct mbuf *m) } #endif - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr = ina; @@ -730,7 +730,7 @@ in_iawithaddr(struct in_addr ina, u_int rtableid) struct in_ifaddr *ia; struct sockaddr_in sin; - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr = ina; @@ -1432,7 +1432,7 @@ ip_forward(struct mbuf *m, int srcrt) * acts as a temporary storage not intended to be * passed down the IP stack or to the mfree. */ - bzero(&mfake.m_hdr, sizeof(mfake.m_hdr)); + memset(&mfake.m_hdr, 0, sizeof(mfake.m_hdr)); mfake.m_type = m->m_type; if (m_dup_pkthdr(&mfake, m, M_DONTWAIT) == 0) { mfake.m_data = mfake.m_pktdat; @@ -1690,7 +1690,7 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip, if ((ifp = m->m_pkthdr.rcvif) == NULL || ifp->if_sadl == NULL) { - bzero(&sdl, sizeof(sdl)); + memset(&sdl, 0, sizeof(sdl)); sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]); sdl.sdl_family = AF_LINK; sdl.sdl_index = ifp != NULL ? ifp->if_index : 0; diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 64a57147fb0..f0dba810a49 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.32 2013/05/14 14:29:08 mpi Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.33 2014/01/09 06:29:06 tedu Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -119,7 +119,7 @@ ipcomp_init(tdbp, xsp, ii) tdbp->tdb_xform = xsp; /* Initialize crypto session */ - bzero(&cric, sizeof(cric)); + memset(&cric, 0, sizeof(cric)); cric.cri_alg = tdbp->tdb_compalgxform->type; return crypto_newsession(&tdbp->tdb_cryptoid, &cric, 0); @@ -396,7 +396,7 @@ ipcomp_output(m, tdb, mp, skip, protoff) if (encif->if_bpf) { struct enchdr hdr; - bzero (&hdr, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); hdr.af = tdb->tdb_dst.sa.sa_family; hdr.spi = tdb->tdb_spi; @@ -632,7 +632,7 @@ ipcomp_output_cb(cp) /* Initialize the IPCOMP header */ ipcomp = mtod(mo, struct ipcomp *); - bzero(ipcomp, sizeof(struct ipcomp)); + memset(ipcomp, 0, sizeof(struct ipcomp)); cpi = (u_int16_t) ntohl(tdb->tdb_spi); ipcomp->ipcomp_cpi = htons(cpi); diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 0f53b582be8..4bf78b72421 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.192 2013/11/11 09:15:34 mpi Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.193 2014/01/09 06:29:06 tedu Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -299,7 +299,7 @@ gettdb(u_int rdomain, u_int32_t spi, union sockaddr_union *dst, u_int8_t proto) for (tdbp = tdbh[hashval]; tdbp != NULL; tdbp = tdbp->tdb_hnext) if ((tdbp->tdb_spi == spi) && (tdbp->tdb_sproto == proto) && (tdbp->tdb_rdomain == rdomain) && - !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) + !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) break; return tdbp; @@ -329,14 +329,14 @@ gettdbbysrcdst(u_int rdomain, u_int32_t spi, union sockaddr_union *src, (tdbp->tdb_rdomain == rdomain) && ((tdbp->tdb_flags & TDBF_INVALID) == 0) && (tdbp->tdb_dst.sa.sa_family == AF_UNSPEC || - !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) && - !bcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa))) + !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) && + !memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa))) break; if (tdbp != NULL) return (tdbp); - bzero(&su_null, sizeof(su_null)); + memset(&su_null, 0, sizeof(su_null)); su_null.sa.sa_len = sizeof(struct sockaddr); hashval = tdb_hash(rdomain, 0, &su_null, proto); @@ -346,7 +346,7 @@ gettdbbysrcdst(u_int rdomain, u_int32_t spi, union sockaddr_union *src, (tdbp->tdb_rdomain == rdomain) && ((tdbp->tdb_flags & TDBF_INVALID) == 0) && (tdbp->tdb_dst.sa.sa_family == AF_UNSPEC || - !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) && + !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) && tdbp->tdb_src.sa.sa_family == AF_UNSPEC) break; @@ -397,9 +397,9 @@ ipsp_aux_match(struct tdb *tdb, * most problems (all this will do is make every * policy get its own SAs). */ - if (bcmp(&tdb->tdb_filter, pfilter, + if (memcmp(&tdb->tdb_filter, pfilter, sizeof(struct sockaddr_encap)) || - bcmp(&tdb->tdb_filtermask, pfiltermask, + memcmp(&tdb->tdb_filtermask, pfiltermask, sizeof(struct sockaddr_encap))) return 0; } @@ -429,7 +429,7 @@ gettdbbyaddr(u_int rdomain, union sockaddr_union *dst, u_int8_t sproto, if ((tdbp->tdb_sproto == sproto) && (tdbp->tdb_rdomain == rdomain) && ((tdbp->tdb_flags & TDBF_INVALID) == 0) && - (!bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))) { + (!memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))) { /* Do IDs and local credentials match ? */ if (!ipsp_aux_match(tdbp, srcid, dstid, local_cred, NULL, filter, filtermask)) @@ -462,7 +462,7 @@ gettdbbysrc(u_int rdomain, union sockaddr_union *src, u_int8_t sproto, if ((tdbp->tdb_sproto == sproto) && (tdbp->tdb_rdomain == rdomain) && ((tdbp->tdb_flags & TDBF_INVALID) == 0) && - (!bcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))) { + (!memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))) { /* Check whether IDs match */ if (!ipsp_aux_match(tdbp, dstid, srcid, NULL, NULL, filter, filtermask)) @@ -487,7 +487,7 @@ tdb_hashstats(void) return; } - bzero (buckets, sizeof(buckets)); + memset(buckets, 0, sizeof(buckets)); for (i = 0; i <= tdb_hashmask; i++) { cnt = 0; for (tdbp = tdbh[i]; cnt < NBUCKETS - 1 && tdbp != NULL; @@ -1088,7 +1088,7 @@ ipsp_ref_match(struct ipsec_ref *ref1, struct ipsec_ref *ref2) { if (ref1->ref_type != ref2->ref_type || ref1->ref_len != ref2->ref_len || - bcmp(ref1 + 1, ref2 + 1, ref1->ref_len)) + memcmp(ref1 + 1, ref2 + 1, ref1->ref_len)) return 0; return 1; @@ -1170,7 +1170,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) return SLIST_FIRST(&tags); tdbi = (struct tdb_ident *) (mtag + 1); - bzero(tdbi, sizeof(struct tdb_ident)); + memset(tdbi, 0, sizeof(struct tdb_ident)); m_copydata(m, off + sizeof(u_int32_t), sizeof(u_int32_t), @@ -1205,7 +1205,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) u_int32_t spi; m_copydata(m, off, sizeof(u_int32_t), (caddr_t) &spi); - bzero(&su, sizeof(union sockaddr_union)); + memset(&su, 0, sizeof(union sockaddr_union)); s = splsoftnet(); @@ -1264,7 +1264,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) return SLIST_FIRST(&tags); tdbi = (struct tdb_ident *) (mtag + 1); - bzero(tdbi, sizeof(struct tdb_ident)); + memset(tdbi, 0, sizeof(struct tdb_ident)); /* Get SPI off the relevant header. */ if (proto == IPPROTO_AH) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index d0ec3bfb52d..7134a397842 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.63 2013/10/27 20:57:39 deraadt Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.64 2014/01/09 06:29:06 tedu Exp $ */ /* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */ /* @@ -543,7 +543,7 @@ ip_mrouter_init(struct socket *so, struct mbuf *m) ip_mrouter = so; mfchashtbl = hashinit(MFCTBLSIZ, M_MRTABLE, M_WAITOK, &mfchash); - bzero((caddr_t)nexpire, sizeof(nexpire)); + memset(nexpire, 0, sizeof(nexpire)); pim_assert = 0; @@ -603,12 +603,12 @@ ip_mrouter_done() } } - bzero((caddr_t)nexpire, sizeof(nexpire)); + memset(nexpire, 0, sizeof(nexpire)); free(mfchashtbl, M_MRTABLE); mfchashtbl = NULL; bw_upcalls_n = 0; - bzero(bw_meter_timers, sizeof(bw_meter_timers)); + memset(bw_meter_timers, 0, sizeof(bw_meter_timers)); /* Reset de-encapsulation cache. */ have_encap_tunnel = 0; @@ -821,11 +821,11 @@ add_vif(struct mbuf *m) log(LOG_DEBUG, "Adding a register vif, ifp: %p\n", (void *)ifp); if (reg_vif_num == VIFI_INVALID) { - bzero(ifp, sizeof(*ifp)); + memset(ifp, 0, sizeof(*ifp)); snprintf(ifp->if_xname, sizeof ifp->if_xname, "register_vif"); ifp->if_flags = IFF_LOOPBACK; - bzero(&vifp->v_route, sizeof(vifp->v_route)); + memset(&vifp->v_route, 0, sizeof(vifp->v_route)); reg_vif_num = vifcp->vifc_vifi; } #endif @@ -898,7 +898,7 @@ reset_vif(struct vif *vifp) ifp = vifp->v_ifp; (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr); } - bzero((caddr_t)vifp, sizeof(*vifp)); + memset(vifp, 0, sizeof(*vifp)); } /* @@ -952,7 +952,7 @@ vif_delete(struct ifnet *ifp) for (i = 0; i < numvifs; i++) { vifp = &viftable[i]; if (vifp->v_ifp == ifp) - bzero((caddr_t)vifp, sizeof *vifp); + memset(vifp, 0, sizeof(*vifp)); } for (i = numvifs; i > 0; i--) @@ -1058,7 +1058,7 @@ add_mfc(struct mbuf *m) } else { struct mfcctl *mp = mtod(m, struct mfcctl *); bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp)); - bzero((caddr_t)&mfcctl2 + sizeof(struct mfcctl), + memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0, sizeof(mfcctl2) - sizeof(struct mfcctl)); } mfccp = &mfcctl2; @@ -1190,7 +1190,7 @@ del_mfc(struct mbuf *m) return (EINVAL); bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp)); - bzero((caddr_t)&mfcctl2 + sizeof(struct mfcctl), + memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0, sizeof(mfcctl2) - sizeof(struct mfcctl)); mfccp = &mfcctl2; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 896e5c6accc..1c1c0b534a7 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.253 2013/12/17 02:41:07 matthew Exp $ */ +/* $OpenBSD: ip_output.c,v 1.254 2014/01/09 06:29:06 tedu Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -170,7 +170,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, if (ro == 0) { ro = &iproute; - bzero((caddr_t)ro, sizeof (*ro)); + memset(ro, 0, sizeof(*ro)); } dst = satosin(&ro->ro_dst); @@ -300,7 +300,7 @@ reroute: if (tdbi->spi == tdb->tdb_spi && tdbi->proto == tdb->tdb_sproto && tdbi->rdomain == tdb->tdb_rdomain && - !bcmp(&tdbi->dst, &tdb->tdb_dst, + !memcmp(&tdbi->dst, &tdb->tdb_dst, sizeof(union sockaddr_union))) { sproto = 0; /* mark as no-IPsec-needed */ goto done_spd; @@ -336,7 +336,7 @@ reroute: } else if (donerouting == 0) { if (ro == 0) { ro = &iproute; - bzero((caddr_t)ro, sizeof (*ro)); + memset(ro, 0, sizeof(*ro)); } dst = satosin(&ro->ro_dst); @@ -1622,7 +1622,7 @@ ip_pcbopts(struct mbuf **pcbopt, struct mbuf *m) m->m_len += sizeof(struct in_addr); cp = mtod(m, u_char *) + sizeof(struct in_addr); memmove((caddr_t)cp, mtod(m, caddr_t), (unsigned)cnt); - bzero(mtod(m, caddr_t), sizeof(struct in_addr)); + memset(mtod(m, caddr_t), 0, sizeof(struct in_addr)); for (; cnt > 0; cnt -= optlen, cp += optlen) { opt = cp[IPOPT_OPTVAL]; diff --git a/sys/netinet/ip_spd.c b/sys/netinet/ip_spd.c index 00ce081307a..795bc0381d0 100644 --- a/sys/netinet/ip_spd.c +++ b/sys/netinet/ip_spd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_spd.c,v 1.69 2013/10/24 11:31:43 mpi Exp $ */ +/* $OpenBSD: ip_spd.c,v 1.70 2014/01/09 06:29:06 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -117,9 +117,9 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, return NULL; } - bzero((caddr_t) re, sizeof(struct route_enc)); - bzero((caddr_t) &sdst, sizeof(union sockaddr_union)); - bzero((caddr_t) &ssrc, sizeof(union sockaddr_union)); + memset(re, 0, sizeof(struct route_enc)); + memset(&sdst, 0, sizeof(union sockaddr_union)); + memset(&ssrc, 0, sizeof(union sockaddr_union)); ddst = (struct sockaddr_encap *) &re->re_dst; ddst->sen_family = PF_KEY; ddst->sen_len = SENT_LEN; @@ -309,8 +309,8 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, #ifdef INET6 case AF_INET6: if ((IN6_IS_ADDR_UNSPECIFIED(&ipo->ipo_dst.sin6.sin6_addr)) || - (bcmp(&ipo->ipo_dst.sin6.sin6_addr, &in6mask128, - sizeof(in6mask128)) == 0)) + (memcmp(&ipo->ipo_dst.sin6.sin6_addr, &in6mask128, + sizeof(in6mask128)) == 0)) dignore = 1; break; #endif /* INET6 */ @@ -365,7 +365,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, (inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) { /* Direct match. */ if (dignore || - !bcmp(&sdst, &ipo->ipo_dst, sdst.sa.sa_len)) { + !memcmp(&sdst, &ipo->ipo_dst, sdst.sa.sa_len)) { *error = 0; return NULL; } @@ -375,9 +375,9 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, if (ipo->ipo_tdb) { if ((ipo->ipo_last_searched <= ipsec_last_added) || (ipo->ipo_sproto != ipo->ipo_tdb->tdb_sproto) || - bcmp(dignore ? &sdst : &ipo->ipo_dst, - &ipo->ipo_tdb->tdb_dst, - ipo->ipo_tdb->tdb_dst.sa.sa_len)) + memcmp(dignore ? &sdst : &ipo->ipo_dst, + &ipo->ipo_tdb->tdb_dst, + ipo->ipo_tdb->tdb_dst.sa.sa_len)) goto nomatchout; if (!ipsp_aux_match(ipo->ipo_tdb, @@ -468,7 +468,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, direction, tdbp, inp, ipo); } - if (bcmp(dignore ? &ssrc : &ipo->ipo_dst, + if (memcmp(dignore ? &ssrc : &ipo->ipo_dst, &tdbp->tdb_src, tdbp->tdb_src.sa.sa_len) || (ipo->ipo_sproto != tdbp->tdb_sproto)) goto nomatchin; @@ -514,9 +514,9 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction, * policy. */ if (ipo->ipo_sproto == ipo->ipo_tdb->tdb_sproto && - !bcmp(&ipo->ipo_tdb->tdb_src, - dignore ? &ssrc : &ipo->ipo_dst, - ipo->ipo_tdb->tdb_src.sa.sa_len)) + !memcmp(&ipo->ipo_tdb->tdb_src, + dignore ? &ssrc : &ipo->ipo_dst, + ipo->ipo_tdb->tdb_src.sa.sa_len)) goto skipinputsearch; /* Not applicable, unlink. */ @@ -603,7 +603,7 @@ ipsec_delete_policy(struct ipsec_policy *ipo) /* Delete from SPD. */ if (!(ipo->ipo_flags & IPSP_POLICY_SOCKET)) { - bzero(&info, sizeof(info)); + memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = (struct sockaddr *)&ipo->ipo_addr; info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&ipo->ipo_mask; @@ -764,7 +764,7 @@ ipsp_pending_acquire(struct ipsec_policy *ipo, union sockaddr_union *gw) struct ipsec_acquire *ipa; TAILQ_FOREACH (ipa, &ipo->ipo_acquires, ipa_ipo_next) { - if (!bcmp(gw, &ipa->ipa_addr, gw->sa.sa_len)) + if (!memcmp(gw, &ipa->ipa_addr, gw->sa.sa_len)) return ipa; } @@ -986,14 +986,11 @@ ipsp_spd_inp(struct mbuf *m, int af, int hlen, int *error, int direction, * accept the packet; otherwise, discard. */ if (tdbp->tdb_sproto == inp->inp_ipo->ipo_sproto && - !bcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst, - SA_LEN(&tdbp->tdb_src.sa)) && - ipsp_aux_match(tdbp, - inp->inp_ipo->ipo_srcid, - inp->inp_ipo->ipo_dstid, - NULL, NULL, - &inp->inp_ipo->ipo_addr, - &inp->inp_ipo->ipo_mask)) + !memcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst, + SA_LEN(&tdbp->tdb_src.sa)) && + ipsp_aux_match(tdbp, inp->inp_ipo->ipo_srcid, + inp->inp_ipo->ipo_dstid, NULL, NULL, + &inp->inp_ipo->ipo_addr, &inp->inp_ipo->ipo_mask)) goto justreturn; else { *error = -EINVAL; @@ -1011,14 +1008,11 @@ ipsp_spd_inp(struct mbuf *m, int af, int hlen, int *error, int direction, */ if (tdbp != NULL && tdbp->tdb_sproto == inp->inp_ipo->ipo_sproto && - !bcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst, - SA_LEN(&tdbp->tdb_src.sa)) && - ipsp_aux_match(tdbp, - inp->inp_ipo->ipo_srcid, - inp->inp_ipo->ipo_dstid, - NULL, NULL, - &inp->inp_ipo->ipo_addr, - &inp->inp_ipo->ipo_mask)) + !memcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst, + SA_LEN(&tdbp->tdb_src.sa)) && + ipsp_aux_match(tdbp, inp->inp_ipo->ipo_srcid, + inp->inp_ipo->ipo_dstid, NULL, NULL, + &inp->inp_ipo->ipo_addr, &inp->inp_ipo->ipo_mask)) goto justreturn; /* diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c index 1721aabe284..5b9a36fb437 100644 --- a/sys/netinet/ipsec_input.c +++ b/sys/netinet/ipsec_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_input.c,v 1.118 2013/11/11 09:15:35 mpi Exp $ */ +/* $OpenBSD: ipsec_input.c,v 1.119 2014/01/09 06:29:06 tedu Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -201,7 +201,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto, * IP packet ready to go through input processing. */ - bzero(&dst_address, sizeof(dst_address)); + memset(&dst_address, 0, sizeof(dst_address)); dst_address.sa.sa_family = af; switch (af) { @@ -997,7 +997,7 @@ ipsec_common_ctlinput(u_int rdomain, int cmd, struct sockaddr *sa, if (mtu < 296) return (NULL); - bzero(&dst, sizeof(struct sockaddr_in)); + memset(&dst, 0, sizeof(struct sockaddr_in)); dst.sin_family = AF_INET; dst.sin_len = sizeof(struct sockaddr_in); dst.sin_addr.s_addr = ip->ip_dst.s_addr; @@ -1060,12 +1060,12 @@ udpencap_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) if (mtu < 296) return (NULL); - bzero(&dst, sizeof(dst)); + memset(&dst, 0, sizeof(dst)); dst.sin_family = AF_INET; dst.sin_len = sizeof(struct sockaddr_in); dst.sin_addr.s_addr = ip->ip_dst.s_addr; su_dst = (union sockaddr_union *)&dst; - bzero(&src, sizeof(src)); + memset(&src, 0, sizeof(src)); src.sin_family = AF_INET; src.sin_len = sizeof(struct sockaddr_in); src.sin_addr.s_addr = ip->ip_src.s_addr; @@ -1076,10 +1076,10 @@ udpencap_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) for (; tdbp != NULL; tdbp = tdbp->tdb_snext) { if (tdbp->tdb_sproto == IPPROTO_ESP && - ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP)) - == TDBF_UDPENCAP) && - !bcmp(&tdbp->tdb_dst, &dst, SA_LEN(&su_dst->sa)) && - !bcmp(&tdbp->tdb_src, &src, SA_LEN(&su_src->sa))) { + ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP)) == + TDBF_UDPENCAP) && + !memcmp(&tdbp->tdb_dst, &dst, SA_LEN(&su_dst->sa)) && + !memcmp(&tdbp->tdb_src, &src, SA_LEN(&su_src->sa))) { if ((adjust = ipsec_hdrsz(tdbp)) != -1) { /* Store adjusted MTU in tdb */ tdbp->tdb_mtu = mtu - adjust;