From 73f71ddda7ebd2b57281c7c546138408c8a289ee Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 17 Sep 2017 11:23:40 +0700 Subject: Check final padding character in Base64 data. --- crypto/src/util/encoders/Base64Encoder.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crypto/src/util/encoders/Base64Encoder.cs') diff --git a/crypto/src/util/encoders/Base64Encoder.cs b/crypto/src/util/encoders/Base64Encoder.cs index 7b53df25a..07294c9a6 100644 --- a/crypto/src/util/encoders/Base64Encoder.cs +++ b/crypto/src/util/encoders/Base64Encoder.cs @@ -269,6 +269,9 @@ namespace Org.BouncyCastle.Utilities.Encoders { if (c3 == padding) { + if (c4 != padding) + throw new IOException("invalid characters encountered at end of base64 data"); + byte b1 = decodingTable[c1]; byte b2 = decodingTable[c2]; -- cgit 1.5.1