Skip to content

Commit

Permalink
internal/exec/util/passwd: plug fd leak in error path
Browse files Browse the repository at this point in the history
Doesn't really matter since we'll likely bubble all the way to the exit
anyway, but it's good practice.
  • Loading branch information
jlebon committed Apr 20, 2022
1 parent ce4b6e9 commit 78538da
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/exec/util/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func writeAuthKeysFile(u *user.User, fp string, keys []byte) error {
return fmt.Errorf("opening file %q as user %s and group %s: %w", fp, u.Uid, u.Gid, err)
}
if _, err = f.Write(keys); err != nil {
f.Close() // ignore errors
return fmt.Errorf("writing file %q: %w", fp, err)
}
if err := f.Close(); err != nil {
Expand Down

0 comments on commit 78538da

Please sign in to comment.