0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-13 22:58:42 +00:00

Adds check for buffer size in OSPF LSA flood.

This commit is contained in:
Ondrej Zajicek 2013-11-22 18:45:57 +01:00
parent 0aeac9cb7f
commit 1fba34a7a1

View File

@ -284,6 +284,16 @@ ospf_lsupd_flood(struct proto_ospf *po,
ospf_pkt_fill_hdr(ifa, pk, LSUPD_P); ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
pk->lsano = htonl(1); 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); lh = (struct ospf_lsa_header *) (pk + 1);
/* Copy LSA into the packet */ /* 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)) if (len2 > ospf_pkt_bufsize(n->ifa))
{ {
/* Cannot fit in a tx buffer, skip that */ /* 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->lsh.type, lsr->lsh.id, lsr->lsh.rt);
lsr = NODE_NEXT(lsr); lsr = NODE_NEXT(lsr);
continue; continue;