Skip to content

Commit

Permalink
fixing consts
Browse files Browse the repository at this point in the history
  • Loading branch information
akshya96 committed Jan 20, 2022
1 parent d138e5c commit 45149f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 3 additions & 8 deletions command/base_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ import (
"strings"
"time"

"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/posener/complete"
)

const (
MaxUint = ^uint(0)
MaxInt = int(MaxUint >> 1)
MinInt = -MaxInt - 1
)

// FlagExample is an interface which declares an example value.
type FlagExample interface {
Example() string
Expand Down Expand Up @@ -252,7 +247,7 @@ func (i *intValue) Set(s string) error {
if err != nil {
return err
}
if v >= int64(MinInt) && v <= int64(MaxInt) {
if v >= int64(consts.MinInt) && v <= int64(consts.MaxInt) {
*i.target = int(v)
return nil
}
Expand Down Expand Up @@ -382,7 +377,7 @@ func (i *uintValue) Set(s string) error {
if err != nil {
return err
}
if v >= 0 && v <= uint64(MaxUint) {
if v >= 0 && v <= uint64(consts.MaxUint) {
*i.target = uint(v)
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions vault/barrier_aes_gcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"sync"
"time"

"github.com/hashicorp/vault/sdk/helper/consts"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/hashicorp/vault/sdk/helper/jsonutil"
Expand All @@ -33,7 +35,6 @@ const (

autoRotateCheckInterval = 5 * time.Minute
legacyRotateReason = "legacy rotation"
MaxInt = int(^uint(0) >> 1)
)

// Versions of the AESGCM storage methodology
Expand Down Expand Up @@ -962,7 +963,7 @@ func (b *AESGCMBarrier) encrypt(path string, term uint32, gcm cipher.AEAD, plain
// nonce, GCM tag and the plaintext

extra := termSize + 1 + gcm.NonceSize() + gcm.Overhead()
if len(plain) > MaxInt-extra {
if len(plain) > consts.MaxInt-extra {
return nil, ErrPlaintextTooLarge
}

Expand Down

0 comments on commit 45149f8

Please sign in to comment.