Skip to content

Commit

Permalink
roachtest: handle errors in filepath.Walk
Browse files Browse the repository at this point in the history
Previously, the function passed to `filepath.Walk` would ignore
errors, which is wrong: when there is an error, the `info` argument is
nil, which would cause roachtest to crash with a nil pointer
dereference.

In this commit, we first check if there was an error walking the
directory, and return it if so.

Epic: none

Release note: None
  • Loading branch information
renatolabs committed Mar 6, 2024
1 parent 38207ee commit d649bd9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,9 @@ func (c *clusterImpl) RefetchCertsFromNode(ctx context.Context, node int) error
}
// Need to prevent world readable files or lib/pq will complain.
return filepath.Walk(c.localCertsDir, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return errors.Wrap(err, "walking localCertsDir failed")
}
if info.IsDir() {
return nil
}
Expand Down

0 comments on commit d649bd9

Please sign in to comment.