Skip to content

Commit

Permalink
more path validation
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Dec 9, 2024
1 parent 8138490 commit e71c233
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hscontrol/dns/extrarecords.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ func NewExtraRecordsMan(path string) (*ExtraRecordsMan, error) {
}
defer watcher.Close()

fi, err := os.Stat(path)
if err != nil {
return nil, fmt.Errorf("getting file info: %w", err)
}

if fi.IsDir() {
return nil, fmt.Errorf("path is a directory, only file is supported: %s", path)
}

err = watcher.Add(path)
if err != nil {
return nil, fmt.Errorf("adding path to watcher: %w", err)
Expand Down

0 comments on commit e71c233

Please sign in to comment.