From 553fbace0ea074932ff7416197dc4e6932e4c3e9 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Wed, 29 May 2024 15:28:13 +0930 Subject: [PATCH] packetbeat/route: improve netsh output handling --- packetbeat/route/route_windows_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packetbeat/route/route_windows_test.go b/packetbeat/route/route_windows_test.go index 3968c187fc75..f216dabc3389 100644 --- a/packetbeat/route/route_windows_test.go +++ b/packetbeat/route/route_windows_test.go @@ -60,6 +60,9 @@ func defaultRoute(af int) (name string, index int, err error) { inTable = f[0] == "-------" continue } + if len(f) < 5 { + return "", -1, fmt.Errorf("unexpected netsh %s line: %q\n\n%s", name, sc.Text(), r) + } if strings.Contains(f[3], "/") { ip, _, err := net.ParseCIDR(f[3]) if err != nil || !ip.IsUnspecified() { @@ -98,7 +101,7 @@ func defaultRoute(af int) (name string, index int, err error) { continue } if len(f) < 5 { - return "", -1, fmt.Errorf("unexpected netsh %s line: %q", name, sc.Text()) + return "", -1, fmt.Errorf("unexpected netsh %s line: %q\n\n%s", name, sc.Text(), d) } idx, err := strconv.Atoi(f[0]) if err != nil {