Skip to content

Commit

Permalink
fix: validate IP address returned as HTTP response in platform code
Browse files Browse the repository at this point in the history
If provider returns empty response, it is parsed as `nil` IP address and
included in the response which leads to `<nil>` entries in the machine
configuration after applying dynamic config.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Aug 25, 2021
1 parent c9af8f7 commit 80b5f0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ func (a *AWS) ExternalIPs(ctx context.Context) (addrs []net.IP, err error) {
return
}

addrs = append(addrs, net.ParseIP(string(body)))
if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}

return addrs, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func (d *DigitalOcean) ExternalIPs(ctx context.Context) (addrs []net.IP, err err
return
}

addrs = append(addrs, net.ParseIP(string(body)))
if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}

return addrs, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func (a *Openstack) ExternalIPs(ctx context.Context) (addrs []net.IP, err error)
return
}

addrs = append(addrs, net.ParseIP(string(body)))
if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}

return addrs, err
}
Expand Down

0 comments on commit 80b5f0e

Please sign in to comment.