Use ibuf_data() instead of directly accessing ibuf->buf.
authorclaudio <claudio@openbsd.org>
Mon, 3 Jul 2023 09:40:47 +0000 (09:40 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 3 Jul 2023 09:40:47 +0000 (09:40 +0000)
OK tb@

usr.sbin/ospfd/auth.c
usr.sbin/ospfd/ospfe.c
usr.sbin/ospfd/packet.c

index 204d4b3..8db5b61 100644 (file)
@@ -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 <norby@openbsd.org>
@@ -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);
 
index dda1090..0cc8470 100644 (file)
@@ -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 <claudio@openbsd.org>
@@ -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);
 }
index 613556a..3337271 100644 (file)
@@ -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 <norby@openbsd.org>
@@ -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);