fix brute force searcher offsets

the brute force searcher offsets were off by one. this change means the offset returned is now aligned with the object number in the object number/generation/operator triple.
This commit is contained in:
Eliot Jones
2020-02-24 12:24:18 +00:00
parent 7ac3fb2a39
commit d6d3869fe2
4 changed files with 167 additions and 98 deletions

View File

@@ -5,7 +5,6 @@
using System.Globalization;
using System.Text;
using Core;
using Exceptions;
using Util.JetBrains.Annotations;
/// <summary>
@@ -49,10 +48,6 @@
bool endobjFound = false;
do
{
if (loopProtection >= 700_000)
{
}
if (loopProtection > 1_000_000)
{
throw new PdfDocumentFormatException("Failed to brute-force search the file due to an infinite loop.");
@@ -142,7 +137,7 @@
var obj = long.Parse(objectNumberBytes.ToString(), CultureInfo.InvariantCulture);
var generation = int.Parse(generationBytes.ToString(), CultureInfo.InvariantCulture);
results[new IndirectReference(obj, generation)] = bytes.CurrentOffset + 1;
results[new IndirectReference(obj, generation)] = bytes.CurrentOffset;
inObject = true;
endobjFound = false;