summaryrefslogtreecommitdiff
path: root/proto/ospf/lsupd.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-11-22 18:45:57 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2013-11-22 18:45:57 +0100
commit1fba34a7a1e245f08212a31a65030230da8c451d (patch)
treebdd103226562a9de3bcaa5d08f14b1c1eb79b167 /proto/ospf/lsupd.c
parent0aeac9cb7f9887374ce0258c8653f9518529bf08 (diff)
Adds check for buffer size in OSPF LSA flood.
Diffstat (limited to 'proto/ospf/lsupd.c')
-rw-r--r--proto/ospf/lsupd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index b19f2619..beac6c83 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -284,6 +284,16 @@ ospf_lsupd_flood(struct proto_ospf *po,
ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
pk->lsano = htonl(1);
+ /* Check iface buffer size */
+ int len2 = sizeof(struct ospf_lsupd_packet) + (hn ? ntohs(hn->length) : hh->length);
+ if (len2 > ospf_pkt_bufsize(ifa))
+ {
+ /* Cannot fit in a tx buffer, skip that iface */
+ log(L_ERR "OSPF: LSA too large to flood on %s (Type: %04x, Id: %R, Rt: %R)",
+ ifa->iface->name, hh->type, hh->id, hh->rt);
+ continue;
+ }
+
lh = (struct ospf_lsa_header *) (pk + 1);
/* Copy LSA into the packet */
@@ -399,7 +409,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
if (len2 > ospf_pkt_bufsize(n->ifa))
{
/* Cannot fit in a tx buffer, skip that */
- log(L_WARN "OSPF: LSA too large to send (Type: %04x, Id: %R, Rt: %R)",
+ log(L_ERR "OSPF: LSA too large to send (Type: %04x, Id: %R, Rt: %R)",
lsr->lsh.type, lsr->lsh.id, lsr->lsh.rt);
lsr = NODE_NEXT(lsr);
continue;