bgpd: Fix infinite loop in MRT route dump for oversized paths#22082
Conversation
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 |
✅ Backports have been createdDetails
|
Greptile SummaryThis PR fixes an infinite loop in
Confidence Score: 5/5Safe to merge — both the infinite loop and the zero-entry record emission are correctly fixed with no new regressions introduced. The two new guards are logically sound, tightly scoped, and correctly interlock: stream_reset at function entry means the partially-written obuf is harmlessly discarded on the next call, and the early return on entry_count == 0 means no corrupt record reaches the MRT file. The previous reviewer's concern about zero-entry records is fully addressed. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[bgp_dump_route_node_record called with path, seq] --> B[stream_reset obuf, build MRT header + prefix]
B --> C{for loop: path != NULL}
C -- yes --> D[Write peer_index, originated, addpath_id, attributes to obuf]
D --> E{cur_endp > max packet size?}
E -- no --> F[entry_count++, endp = cur_endp, path = path.next]
F --> C
E -- yes --> G[stream_set_endp obuf endp - revert oversized write]
G --> H{entry_count == 0? single path too large}
H -- yes --> I[flog_warn: skipping oversized path, path = path.next]
I --> J[break]
H -- no --> J
C -- path == NULL --> K[exit loop normally]
J --> L{entry_count == 0?}
K --> L
L -- yes --> M[return path - no fwrite, skip zero-entry record]
L -- no --> N[stream_putw_at sizep entry_count, bgp_dump_set_size, fwrite to MRT file]
N --> O[return path - next batch starts here]
Reviews (2): Last reviewed commit: "bgpd: Fix infinite loop in MRT route dum..." | Re-trigger Greptile |
This is a complete fix for CVE-2016-4049. Fixes: 246556b ("bgpd: Fix buffer overflow error in bgp_dump_routes_func") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
3db6044 to
553f44e
Compare
bgpd: Fix infinite loop in MRT route dump for oversized paths (backport #22082)
bgpd: Fix infinite loop in MRT route dump for oversized paths (backport #22082)
bgpd: Fix infinite loop in MRT route dump for oversized paths (backport #22082)
bgpd: Fix infinite loop in MRT route dump for oversized paths (backport #22082)
bgpd: Fix infinite loop in MRT route dump for oversized paths (backport #22082)
No description provided.