From: claudio Date: Mon, 3 Jul 2023 09:40:47 +0000 (+0000) Subject: Use ibuf_data() instead of directly accessing ibuf->buf. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a50d52cbc85454f3ffb15fac044a60f45bc7d004;p=openbsd Use ibuf_data() instead of directly accessing ibuf->buf. OK tb@ --- diff --git a/usr.sbin/ospfd/auth.c b/usr.sbin/ospfd/auth.c index 204d4b33e6c..8db5b61096f 100644 --- a/usr.sbin/ospfd/auth.c +++ b/usr.sbin/ospfd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.21 2023/06/20 15:19:55 claudio Exp $ */ +/* $OpenBSD: auth.c,v 1.22 2023/07/03 09:40:47 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -154,13 +154,13 @@ auth_gen(struct ibuf *buf, struct iface *iface) switch (iface->auth_type) { case AUTH_NONE: - chksum = in_cksum(buf->buf, ibuf_size(buf)); + chksum = in_cksum(ibuf_data(buf), ibuf_size(buf)); if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum), &chksum, sizeof(chksum)) == -1) fatalx("auth_gen: ibuf_set failed"); break; case AUTH_SIMPLE: - chksum = in_cksum(buf->buf, ibuf_size(buf)); + chksum = in_cksum(ibuf_data(buf), ibuf_size(buf)); if (ibuf_set(buf, offsetof(struct ospf_hdr, chksum), &chksum, sizeof(chksum)) == -1) fatalx("auth_gen: ibuf_set failed"); @@ -193,7 +193,7 @@ auth_gen(struct ibuf *buf, struct iface *iface) /* calculate MD5 digest */ MD5Init(&hash); - MD5Update(&hash, buf->buf, ibuf_size(buf)); + MD5Update(&hash, ibuf_data(buf), ibuf_size(buf)); MD5Update(&hash, digest, MD5_DIGEST_LENGTH); MD5Final(digest, &hash); diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index dda1090db38..0cc8470de76 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.112 2023/06/20 15:19:55 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.113 2023/07/03 09:40:47 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -1099,13 +1099,13 @@ orig_rtr_lsa(struct area *area) if (ibuf_set(buf, 0, &lsa_hdr, sizeof(lsa_hdr)) == -1) fatal("orig_rtr_lsa: ibuf_set failed"); - chksum = iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET); + chksum = iso_cksum(ibuf_data(buf), ibuf_size(buf), LS_CKSUM_OFFSET); if (ibuf_set_n16(buf, LS_CKSUM_OFFSET, chksum) == -1) fatal("orig_rtr_lsa: ibuf_set_n16 failed"); if (self && num_links) imsg_compose_event(iev_rde, IMSG_LS_UPD, self->peerid, 0, - -1, buf->buf, ibuf_size(buf)); + -1, ibuf_data(buf), ibuf_size(buf)); else log_warnx("orig_rtr_lsa: empty area %s", inet_ntoa(area->id)); @@ -1165,12 +1165,12 @@ orig_net_lsa(struct iface *iface) if (ibuf_set(buf, 0, &lsa_hdr, sizeof(lsa_hdr)) == -1) fatal("orig_net_lsa: ibuf_set failed"); - chksum = iso_cksum(buf->buf, ibuf_size(buf), LS_CKSUM_OFFSET); + chksum = iso_cksum(ibuf_data(buf), ibuf_size(buf), LS_CKSUM_OFFSET); if (ibuf_set_n16(buf, LS_CKSUM_OFFSET, chksum) == -1) fatal("orig_net_lsa: ibuf_set_n16 failed"); imsg_compose_event(iev_rde, IMSG_LS_UPD, iface->self->peerid, 0, - -1, buf->buf, ibuf_size(buf)); + -1, ibuf_data(buf), ibuf_size(buf)); ibuf_free(buf); } diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c index 613556a4cf6..33372711009 100644 --- a/usr.sbin/ospfd/packet.c +++ b/usr.sbin/ospfd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.36 2021/11/03 21:40:03 sthen Exp $ */ +/* $OpenBSD: packet.c,v 1.37 2023/07/03 09:40:47 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -85,7 +85,7 @@ send_packet(struct iface *iface, struct ibuf *buf, struct sockaddr_in *dst) bzero(&msg, sizeof(msg)); iov[0].iov_base = &ip_hdr; iov[0].iov_len = sizeof(ip_hdr); - iov[1].iov_base = buf->buf; + iov[1].iov_base = ibuf_data(buf); iov[1].iov_len = ibuf_size(buf); msg.msg_name = dst; msg.msg_namelen = sizeof(*dst);