Skip to content

Commit

Permalink
fix: when vm /etc/hosts contains empty line could cause index out of …
Browse files Browse the repository at this point in the history
…range (#446)
  • Loading branch information
XGFan authored Oct 16, 2022
1 parent 659edd2 commit c4536a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion environment/vm/lima/lima.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func includesHost(hostsFileContent, host string, ip net.IP) bool {
scanner := bufio.NewScanner(strings.NewReader(hostsFileContent))
for scanner.Scan() {
str := strings.Fields(scanner.Text())
if str[0] != ip.String() {
if len(str) == 0 || str[0] != ip.String() {
continue
}
if len(str) > 1 && str[1] == host {
Expand Down

0 comments on commit c4536a8

Please sign in to comment.