Skip to content

Commit 3617fb9

Browse files
authored
PR #577: Throw ZipException in ZipAESStream instead of generic Exception
1 parent c814877 commit 3617fb9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ICSharpCode.SharpZipLib/Encryption/ZipAESStream.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Security.Cryptography;
44
using ICSharpCode.SharpZipLib.Core;
5+
using ICSharpCode.SharpZipLib.Zip;
56

67
namespace ICSharpCode.SharpZipLib.Encryption
78
{
@@ -137,14 +138,14 @@ private int ReadAndTransform(byte[] buffer, int offset, int count)
137138
nBytes += TransformAndBufferBlock(buffer, offset, bytesLeftToRead, finalBlock);
138139
}
139140
else if (byteCount < AUTH_CODE_LENGTH)
140-
throw new Exception("Internal error missed auth code"); // Coding bug
141+
throw new ZipException("Internal error missed auth code"); // Coding bug
141142
// Final block done. Check Auth code.
142143
byte[] calcAuthCode = _transform.GetAuthCode();
143144
for (int i = 0; i < AUTH_CODE_LENGTH; i++)
144145
{
145146
if (calcAuthCode[i] != _slideBuffer[_slideBufStartPos + i])
146147
{
147-
throw new Exception("AES Authentication Code does not match. This is a super-CRC check on the data in the file after compression and encryption. \r\n"
148+
throw new ZipException("AES Authentication Code does not match. This is a super-CRC check on the data in the file after compression and encryption. \r\n"
148149
+ "The file may be damaged.");
149150
}
150151
}

0 commit comments

Comments
 (0)