mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
fix bug with handling of more than 256 bytes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
namespace UglyToad.PdfPig.Encryption
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
@@ -28,6 +29,11 @@
|
||||
|
||||
var buffer = new byte[256];
|
||||
|
||||
if (data.Length > 256)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
using (var decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV))
|
||||
using (var input = new MemoryStream(data))
|
||||
using (var output = new MemoryStream())
|
||||
@@ -35,15 +41,15 @@
|
||||
input.Seek(iv.Length, SeekOrigin.Begin);
|
||||
using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
var offset = 0;
|
||||
int read;
|
||||
do
|
||||
{
|
||||
read = cryptoStream.Read(buffer, offset, buffer.Length - offset);
|
||||
read = cryptoStream.Read(buffer, 0, buffer.Length);
|
||||
|
||||
output.Write(buffer, offset, read);
|
||||
|
||||
offset += read;
|
||||
if (read > 0)
|
||||
{
|
||||
output.Write(buffer, 0, read);
|
||||
}
|
||||
} while (read > 0);
|
||||
|
||||
return output.ToArray();
|
||||
|
||||
Reference in New Issue
Block a user