diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-12 09:11:02 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-12 09:11:02 +0530 |
| commit | 7b5328536a82755c2724f2075c31035d709588df (patch) | |
| tree | a56537a5b3d19c695d25ff41f42a670011f23a50 /internal | |
| parent | d3e8c5d00d71e7d3d5186b4dc653d0c10ee35870 (diff) | |
fix usage prompt in non usage errors
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/crypt/rawDecrypt.go | 4 | ||||
| -rw-r--r-- | internal/crypt/rawEncrypt.go | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/internal/crypt/rawDecrypt.go b/internal/crypt/rawDecrypt.go index 30a202f..b82f0fb 100644 --- a/internal/crypt/rawDecrypt.go +++ b/internal/crypt/rawDecrypt.go @@ -26,6 +26,10 @@ func DecryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { return nil, fmt.Errorf("decrypt: failed to parse header length: %w", err) } + if headerLen < 0 || idx+1+headerLen > len(inputBytes) { + return nil, fmt.Errorf("decrypt: invalid header length %d", headerLen) + } + headerBytes := inputBytes[idx+1 : idx+1+headerLen] headers, err := utils.GetFileHeaders(headerBytes) if err != nil { diff --git a/internal/crypt/rawEncrypt.go b/internal/crypt/rawEncrypt.go index 79a1a54..77803e0 100644 --- a/internal/crypt/rawEncrypt.go +++ b/internal/crypt/rawEncrypt.go @@ -2,6 +2,7 @@ package crypt import ( "fmt" + "strconv" "gitlab.com/whiteboardguy/eno/internal/utils" "golang.org/x/crypto/argon2" @@ -34,7 +35,8 @@ func EncryptRawBytes(inputBytes []byte, password []byte) ([]byte, error) { return nil, fmt.Errorf("encrypt: %w", err) } - target := make([]byte, 0, len(headerBytes)+len(encrypted)+20) + lenLen := len(strconv.Itoa(len(headerBytes))) + target := make([]byte, 0, lenLen+1+len(headerBytes)+len(encrypted)) target = fmt.Appendf(target, "%d:", len(headerBytes)) target = append(target, headerBytes...) target = append(target, encrypted...) |