mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
Update passphrase.go
This commit is contained in:
parent
a76d90990c
commit
cfeee2f6fc
1 changed files with 4 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
|
@ -385,6 +386,9 @@ func ensureInt(x interface{}) (int, error) {
|
||||||
case int:
|
case int:
|
||||||
return v, nil
|
return v, nil
|
||||||
case float64:
|
case float64:
|
||||||
|
if math.IsNaN(v) || math.IsInf(v, 0) || v != math.Trunc(v) || v < 0 || v > math.MaxInt32 {
|
||||||
|
return 0, fmt.Errorf("invalid KDF parameter: %v", v)
|
||||||
|
}
|
||||||
return int(v), nil
|
return int(v), nil
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("invalid KDF parameter: expected number, got %T", x)
|
return 0, fmt.Errorf("invalid KDF parameter: expected number, got %T", x)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue