]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs 16292/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 13 Jun 2024 06:00:21 +0000 (09:00 +0300)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 25 Jun 2024 11:27:43 +0000 (11:27 +0000)
When the packet is malformed it can use whatever values it wants. Let's check
what the real data we have in a stream instead of relying on malformed values.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 9929486d6bdb28469a5b626a17d5bc9991c83ce3)

bgpd/bgp_attr.c

index 56b85732354b38bc2581b37186ad15061c6e7565..dd098cb157b50b10373bc5c624aa42ad8631dd90 100644 (file)
@@ -2700,7 +2700,7 @@ static int bgp_attr_encap(struct bgp_attr_parser_args *args)
                }
        }
 
-       while (length >= 4) {
+       while (STREAM_READABLE(BGP_INPUT(peer)) >= 4) {
                uint16_t subtype = 0;
                uint16_t sublength = 0;
                struct bgp_attr_encap_subtlv *tlv;