Check if data is long enough to be decrypted
This commit is contained in:
parent
344864f5b2
commit
1cf537662a
@ -117,6 +117,9 @@ func aesDecrypt(c *Config, ciphertext string) (string, error) {
|
||||
}
|
||||
|
||||
nonceSize := gcm.NonceSize()
|
||||
if len(data) < nonceSize {
|
||||
return "", errors.New("ciphertext too short")
|
||||
}
|
||||
nonce, cipherText := data[:nonceSize], data[nonceSize:]
|
||||
|
||||
plaintext, err := gcm.Open(nil, nonce, cipherText, nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user