collector: add bounds check and test for tcpstat collector (#1134)

Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
Matt Layher 2018-10-27 03:21:36 -04:00 committed by Ben Kochie
commit 778124a56c
2 changed files with 25 additions and 0 deletions

View file

@ -118,6 +118,10 @@ func parseTCPStats(r io.Reader) (map[tcpConnectionState]float64, error) {
if len(parts) == 0 {
continue
}
if len(parts) < 4 {
return nil, fmt.Errorf("invalid TCP stats line: %q", scanner.Text())
}
if strings.HasPrefix(parts[0], "sl") {
continue
}