Skip to content

Commit

Permalink
fix: check address length to avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj committed Jun 26, 2023
1 parent 56aac4f commit d7177c5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/inputs/phpfpm/phpfpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func (p *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
return fmt.Errorf("unable parse server address %q: %w", addr, err)
}
socketAddr := strings.Split(u.Host, ":")
if len(socketAddr) < 2 {
return fmt.Errorf("url does not follow required 'address:port' format: %s", u.Host)
}
fcgiIP := socketAddr[0]
fcgiPort, _ := strconv.Atoi(socketAddr[1])
fcgi, err = newFcgiClient(fcgiIP, fcgiPort)
Expand Down

0 comments on commit d7177c5

Please sign in to comment.