From: claudio Date: Mon, 3 Jul 2023 11:51:27 +0000 (+0000) Subject: Use new ibuf API. Use ibuf_data() and ibuf_size() instead of direct X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8bc5e3a3aaccee091c0a327f1a8daa3593d0f628;p=openbsd Use new ibuf API. Use ibuf_data() and ibuf_size() instead of direct struct access and use ibuf_set_n16() to update the length field. OK tb@ --- diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c index 0b6e1eaddc6..8ba8c4be4b9 100644 --- a/usr.sbin/ldpd/hello.c +++ b/usr.sbin/ldpd/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.58 2019/12/12 00:10:29 yasuoka Exp $ */ +/* $OpenBSD: hello.c,v 1.59 2023/07/03 11:51:27 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal @@ -139,7 +139,7 @@ send_hello(enum hello_type type, struct iface_af *ia, struct tnbr *tnbr) return (-1); } - send_packet(fd, af, &dst, ia, buf->buf, buf->wpos); + send_packet(fd, af, &dst, ia, ibuf_data(buf), ibuf_size(buf)); ibuf_free(buf); return (0); diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c index cfafb4366c0..730f61f288f 100644 --- a/usr.sbin/ldpd/labelmapping.c +++ b/usr.sbin/ldpd/labelmapping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: labelmapping.c,v 1.68 2017/03/04 00:15:35 renato Exp $ */ +/* $OpenBSD: labelmapping.c,v 1.69 2023/07/03 11:51:27 claudio Exp $ */ /* * Copyright (c) 2014, 2015 Renato Westphal @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -39,10 +40,8 @@ static void log_msg_mapping(int, uint16_t, struct nbr *, struct map *); static void enqueue_pdu(struct nbr *nbr, struct ibuf *buf, uint16_t size) { - struct ldp_hdr *ldp_hdr; - - ldp_hdr = ibuf_seek(buf, 0, sizeof(struct ldp_hdr)); - ldp_hdr->length = htons(size); + if (ibuf_set_n16(buf, offsetof(struct ldp_hdr, length), size) == -1) + fatal(__func__); evbuf_enqueue(&nbr->tcp->wbuf, buf); }