Skip to content

Commit 195fb6e

Browse files
committed
(#3765) Don't try to decrypt null strings
The DefaultEncryptionUtility attempts to decrypt a string without checking if the string is null or empty. This commit adds a check the same as in EncryptString whereby we return null if the input string is null or empty.
1 parent 6d82bc0 commit 195fb6e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/chocolatey/infrastructure/cryptography/DefaultEncryptionUtility.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ This is can be because the machine keyfile cannot be written as a normal user.
6161

6262
public string DecryptString(string encryptedString)
6363
{
64+
if (string.IsNullOrEmpty(encryptedString))
65+
{
66+
return null;
67+
}
68+
6469
var encryptedByteArray = Convert.FromBase64String(encryptedString);
6570
byte[] decryptedByteArray;
6671

0 commit comments

Comments
 (0)