mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-23 19:41:58 -08:00
Validate bcrypt-cost config value to prevent silent errors
This commit is contained in:
parent
3c4c5dde4d
commit
462e568f00
3 changed files with 10 additions and 3 deletions
|
|
@ -2337,7 +2337,7 @@ func (ac *AccountCredentials) Serialize() (result string, err error) {
|
|||
return string(credText), nil
|
||||
}
|
||||
|
||||
func (ac *AccountCredentials) SetPassphrase(passphrase string, bcryptCost uint) (err error) {
|
||||
func (ac *AccountCredentials) SetPassphrase(passphrase string, bcryptCost int) (err error) {
|
||||
if passphrase == "" {
|
||||
ac.PassphraseHash = nil
|
||||
ac.SCRAMCreds = SCRAMCreds{}
|
||||
|
|
@ -2348,7 +2348,7 @@ func (ac *AccountCredentials) SetPassphrase(passphrase string, bcryptCost uint)
|
|||
return errAccountBadPassphrase
|
||||
}
|
||||
|
||||
ac.PassphraseHash, err = passwd.GenerateFromPassword([]byte(passphrase), int(bcryptCost))
|
||||
ac.PassphraseHash, err = passwd.GenerateFromPassword([]byte(passphrase), bcryptCost)
|
||||
if err != nil {
|
||||
return errAccountBadPassphrase
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue