mirror of
https://github.com/rclone/rclone.git
synced 2025-01-13 20:38:12 +02:00
config: fix size computation for allocation may overflow
This commit is contained in:
parent
37c12732f9
commit
e439121ab2
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
// crypt internals
|
// crypt internals
|
||||||
@ -47,6 +48,9 @@ func crypt(out, in, iv []byte) error {
|
|||||||
// This is done by encrypting with AES-CTR
|
// This is done by encrypting with AES-CTR
|
||||||
func Obscure(x string) (string, error) {
|
func Obscure(x string) (string, error) {
|
||||||
plaintext := []byte(x)
|
plaintext := []byte(x)
|
||||||
|
if math.MaxInt32-aes.BlockSize < len(plaintext) {
|
||||||
|
return "", fmt.Errorf("value too large")
|
||||||
|
}
|
||||||
ciphertext := make([]byte, aes.BlockSize+len(plaintext))
|
ciphertext := make([]byte, aes.BlockSize+len(plaintext))
|
||||||
iv := ciphertext[:aes.BlockSize]
|
iv := ciphertext[:aes.BlockSize]
|
||||||
if _, err := io.ReadFull(cryptRand, iv); err != nil {
|
if _, err := io.ReadFull(cryptRand, iv); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user