Make arithemetic operations overflow safe (#41)

This commit is contained in:
Pradeep Sekar authored and GitHub committed 2026-02-02 21:25:45 -08:00
1 parent 036c3f2ae5
commit e74f1b661a
2 files changed
+3 -3

No files matched your search

+1 -2
View File
@@ -1,8 +1,7 @@
This product includes software developed at MinIO, Inc.
(https://min.io/).
The Boundary MinIO Plugin contains unmodified
subcomponents of the Minio madmin-go library v1.7.5
The Boundary MinIO Plugin contains subcomponents of the Minio madmin-go library v1.7.5
(https://github.com/minio/madmin-go/tree/v1.7.5),
licensed under the Apache License 2.0.
+2 -1
View File
@@ -80,7 +80,8 @@ func EncryptData(password string, data []byte) ([]byte, error) {
nonce := sioutil.MustRandom(stream.NonceSize())
// ciphertext = salt || AEAD ID | nonce | encrypted data
cLen := int64(len(salt)+1+len(nonce)+len(data)) + stream.Overhead(int64(len(data)))
// cLen calculation: Modified by Hashicorp in 2026 to make arithmetic operations overflow-safe by casting to int64 before addition
cLen := int64(len(salt)) + 1 + int64(len(nonce)) + int64(len(data)) + stream.Overhead(int64(len(data)))
ciphertext := bytes.NewBuffer(make([]byte, 0, cLen)) // pre-alloc correct length
// Prefix the ciphertext with salt, AEAD ID and nonce