From ec9e425712a71115340397f9a3315b3377a4a8f8 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Thu, 27 Feb 2020 17:17:49 +0000 Subject: [PATCH] use length from stream dictionary if directly available when brute forcing we use the length available in the stream's dictionary token if it is a direct number rather than an indirect reference. --- src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs b/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs index 0a747bb2..f9bd430a 100644 --- a/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs +++ b/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs @@ -233,6 +233,11 @@ // Get the expected length from the stream dictionary if present. long? length = getLength ? GetStreamLength(streamDictionaryToken) : default(long?); + if (!getLength && streamDictionaryToken.TryGet(NameToken.Length, out NumericToken inlineLengthToken)) + { + length = inlineLengthToken.Long; + } + // Verify again that we start with "stream" var hasStartStreamToken = ReadStreamTokenStart(inputBytes, startStreamTokenOffset);