fix: tools/cosmovisor: return on failing to remove existing symlink (#14032)

Fixes #14031
Fixes https://github.com/cosmos/cosmos-sdk/security/code-scanning/6794
This commit is contained in:
Emmanuel T Odeke 2022-11-27 03:18:50 -08:00 committed by GitHub
parent 67b2b34bc7
commit ffb0e29179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,7 +286,9 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) {
// remove link if it exists
if _, err := os.Stat(link); err == nil {
os.Remove(link)
if err := os.Remove(link); err != nil {
return fmt.Errorf("failed to remove existing link: %w", err)
}
}
// point to the new directory