diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-15 07:51:06 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-15 07:51:06 +0530 |
| commit | d369e5611df643bd83f951a94b468ef272c1bf3e (patch) | |
| tree | e9b12ca81bafc53cfad7933578f2665e183bf4f2 /internal/crypt/rawDecrypt.go | |
| parent | 8ebc072fb0ceae229196e8d3d8ff15bbbc049fdd (diff) | |
bunch of fixes
defer file.Close() after os.OpenFile
clear(sensitive) before each os.Exit(1)
Shared utils.StdinScanner with 512KB buffer
bytes.Equal for password comparison, append instead of string() + []byte()
Diffstat (limited to 'internal/crypt/rawDecrypt.go')
| -rw-r--r-- | internal/crypt/rawDecrypt.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/crypt/rawDecrypt.go b/internal/crypt/rawDecrypt.go index d1f0193..ede063c 100644 --- a/internal/crypt/rawDecrypt.go +++ b/internal/crypt/rawDecrypt.go @@ -25,7 +25,7 @@ func DecryptBytesPass(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) { + if headerLen <= 0 || idx+1+headerLen > len(inputBytes) { return nil, fmt.Errorf("decrypt: invalid header length %d", headerLen) } @@ -73,7 +73,7 @@ func DecryptBytesSSH(inputBytes []byte, privKeyPath string) ([]byte, error) { return nil, fmt.Errorf("decrypt: failed to parse header length: %w", err) } - if headerLen < 0 || idx+1+headerLen > len(inputBytes) { + if headerLen <= 0 || idx+1+headerLen > len(inputBytes) { return nil, fmt.Errorf("decrypt: invalid header length %d", headerLen) } @@ -137,7 +137,7 @@ func DecryptBytesSSHWithKey(inputBytes []byte, noteKey []byte) ([]byte, error) { return nil, fmt.Errorf("decrypt: failed to parse header length: %w", err) } - if headerLen < 0 || idx+1+headerLen > len(inputBytes) { + if headerLen <= 0 || idx+1+headerLen > len(inputBytes) { return nil, fmt.Errorf("decrypt: invalid header length %d", headerLen) } |