Skip to content

Commit

Permalink
fix: build on 32-bit architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Nov 13, 2024
1 parent eadc5d5 commit e181bf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions hasherx/hash_comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func decodeArgon2idHash(encodedHash string) (p *Argon2Config, salt, hash []byte,
if err != nil {
return nil, nil, nil, err
}
saltLength := len(salt)
saltLength := uint(len(salt))
if saltLength > math.MaxUint32 {
return nil, nil, nil, ErrInvalidHash
}
Expand All @@ -174,7 +174,7 @@ func decodeArgon2idHash(encodedHash string) (p *Argon2Config, salt, hash []byte,
if err != nil {
return nil, nil, nil, err
}
keyLength := len(hash)
keyLength := uint(len(hash))
if keyLength > math.MaxUint32 {
return nil, nil, nil, ErrInvalidHash
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func decodePbkdf2Hash(encodedHash string) (p *PBKDF2Config, salt, hash []byte, e
if err != nil {
return nil, nil, nil, err
}
saltLength := len(salt)
saltLength := uint(len(salt))
if saltLength > math.MaxUint32 {
return nil, nil, nil, ErrInvalidHash
}
Expand All @@ -217,7 +217,7 @@ func decodePbkdf2Hash(encodedHash string) (p *PBKDF2Config, salt, hash []byte, e
if err != nil {
return nil, nil, nil, err
}
keyLength := len(hash)
keyLength := uint(len(hash))
if keyLength > math.MaxUint32 {
return nil, nil, nil, ErrInvalidHash
}
Expand Down
5 changes: 3 additions & 2 deletions mapx/type_assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ func GetInt64[K comparable](values map[K]any, key K) (int64, error) {
case int32:
return int64(v), nil
case uint:
if v > math.MaxInt64 {
vv := uint64(v)
if vv > math.MaxInt64 {
return 0, errors.New("value is out of range")
}
return int64(v), nil
return int64(vv), nil
case uint32:
return int64(v), nil
case uint64:
Expand Down

0 comments on commit e181bf2

Please sign in to comment.