Merge pull request #1556 from robertolarcher/develop

Email Parser: NegativeArraySizeException patch
This commit is contained in:
Richard Cordovano 2015-09-09 10:12:34 -04:00
commit 350fc355c0

View File

@ -254,10 +254,16 @@ class PstParser {
int bufferSize = 8176; int bufferSize = 8176;
byte[] buffer = new byte[bufferSize]; byte[] buffer = new byte[bufferSize];
int count = attachmentStream.read(buffer); int count = attachmentStream.read(buffer);
if(count == -1) {
throw new IOException("attachmentStream invalid (read() fails). File "+attach.getLongFilename()+ " skipped");
}
while (count == bufferSize) { while (count == bufferSize) {
out.write(buffer); out.write(buffer);
count = attachmentStream.read(buffer); count = attachmentStream.read(buffer);
} }
byte[] endBuffer = new byte[count]; byte[] endBuffer = new byte[count];
System.arraycopy(buffer, 0, endBuffer, 0, count); System.arraycopy(buffer, 0, endBuffer, 0, count);
out.write(endBuffer); out.write(endBuffer);