fix DeltaSerializer validation checks and add one more

This commit is contained in:
CasualPokePlayer 2023-04-02 02:19:52 -07:00
parent 6f7f94a06e
commit 86b33bd3ce
1 changed files with 7 additions and 2 deletions

View File

@ -126,7 +126,7 @@ namespace BizHawk.Common
{ {
header = -header; header = -header;
if (header < dataEnd - dataPos || header < deltaEnd - deltaPos) if (dataEnd - dataPos < header || deltaEnd - deltaPos < header)
{ {
throw new InvalidOperationException("Corrupt delta header!"); throw new InvalidOperationException("Corrupt delta header!");
} }
@ -140,7 +140,7 @@ namespace BizHawk.Common
} }
else // sameness block else // sameness block
{ {
if (header < dataEnd - dataPos) if (dataEnd - dataPos < header)
{ {
throw new InvalidOperationException("Corrupt delta header!"); throw new InvalidOperationException("Corrupt delta header!");
} }
@ -150,6 +150,11 @@ namespace BizHawk.Common
dataPos += header; dataPos += header;
} }
if (dataPos != dataEnd)
{
throw new InvalidOperationException("Did not reach end of data after applying delta!");
}
} }
} }
} }