summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2011-03-08 10:56:02 +0000
committerclaudio <claudio@openbsd.org>2011-03-08 10:56:02 +0000
commit6860b38a466659e0f36f228a891202888eecc930 (patch)
treebe30f2a15503fa6c3ff74d440d22f6b677bd769c
parentAdd regression test that checks ENOTSOCK error for non-socket drain. (diff)
downloadwireguard-openbsd-6860b38a466659e0f36f228a891202888eecc930.tar.xz
wireguard-openbsd-6860b38a466659e0f36f228a891202888eecc930.zip
Instead of using IBUF_READ_SIZE as upper bound when building various
packets use a better upper bound based on IP_MAXPACKET. Also change one IBUF_READ_SIZE to READ_BUF_SIZE since that is what the rest of the code uses. Tested and OK sthen@
-rw-r--r--usr.sbin/ospfd/hello.c6
-rw-r--r--usr.sbin/ospfd/ospfe.c14
2 files changed, 11 insertions, 9 deletions
diff --git a/usr.sbin/ospfd/hello.c b/usr.sbin/ospfd/hello.c
index 20b16f964f0..6a323ef5e58 100644
--- a/usr.sbin/ospfd/hello.c
+++ b/usr.sbin/ospfd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.19 2010/05/26 13:56:08 nicm Exp $ */
+/* $OpenBSD: hello.c,v 1.20 2011/03/08 10:56:02 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -64,8 +64,8 @@ send_hello(struct iface *iface)
fatalx("send_hello: unknown interface type");
}
- /* XXX IBUF_READ_SIZE */
- if ((buf = ibuf_dynamic(PKG_DEF_SIZE, IBUF_READ_SIZE)) == NULL)
+ if ((buf = ibuf_dynamic(PKG_DEF_SIZE,
+ IP_MAXPACKET - sizeof(struct ip))) == NULL)
fatal("send_hello");
/* OSPF header */
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 200d8a65c3b..01917c10ede 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.77 2010/10/01 13:29:25 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.78 2011/03/08 10:56:02 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -183,7 +183,7 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2],
TAILQ_INIT(&ctl_conns);
control_listen();
- if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL)
+ if ((pkt_ptr = calloc(1, READ_BUF_SIZE)) == NULL)
fatal("ospfe");
/* start interfaces */
@@ -756,8 +756,9 @@ orig_rtr_lsa(struct area *area)
log_debug("orig_rtr_lsa: area %s", inet_ntoa(area->id));
- /* XXX IBUF_READ_SIZE */
- if ((buf = ibuf_dynamic(sizeof(lsa_hdr), READ_BUF_SIZE)) == NULL)
+ if ((buf = ibuf_dynamic(sizeof(lsa_hdr),
+ IP_MAXPACKET - sizeof(struct ip) - sizeof(struct ospf_hdr) -
+ sizeof(u_int32_t) - MD5_DIGEST_LENGTH)) == NULL)
fatal("orig_rtr_lsa");
/* reserve space for LSA header and LSA Router header */
@@ -1024,8 +1025,9 @@ orig_net_lsa(struct iface *iface)
int num_rtr = 0;
u_int16_t chksum;
- /* XXX IBUF_READ_SIZE */
- if ((buf = ibuf_dynamic(sizeof(lsa_hdr), IBUF_READ_SIZE)) == NULL)
+ if ((buf = ibuf_dynamic(sizeof(lsa_hdr),
+ IP_MAXPACKET - sizeof(struct ip) - sizeof(struct ospf_hdr) -
+ sizeof(u_int32_t) - MD5_DIGEST_LENGTH)) == NULL)
fatal("orig_net_lsa");
/* reserve space for LSA header and LSA Router header */