From 1166094a2f0e34ed5308f8729cbd7a637e64e5b1 Mon Sep 17 00:00:00 2001 From: Nick Hutchinson Date: Mon, 4 Jan 2021 11:41:32 +0000 Subject: [PATCH] Fix infinite loop when querying BSD routing table Fix `query_route_table()` returning a buffer padded with extra '\0' bytes because it ignored the buffer size returned by `sysctl()`. This caused `route_entries()` / `route6_entries()` to fall into an infinite loop, forever trying to parse a 0-length routing entry. --- src/utils/routing_utils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/routing_utils.cpp b/src/utils/routing_utils.cpp index d107de8..191803e 100644 --- a/src/utils/routing_utils.cpp +++ b/src/utils/routing_utils.cpp @@ -154,6 +154,7 @@ vector query_route_table(int family) { throw exception_base("sysctl failed"); } + buf.resize(len); return buf; }