Skip to content

Commit

Permalink
fix possible infinite loop while parsing for broken replays (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
diopolgg authored Mar 9, 2024
1 parent c322d58 commit 81138ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Unreal.Core/ReplayReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ public virtual void ReadReplayChunks(FArchive archive)
var chunkSize = archive.ReadInt32();
var offset = archive.Position;

if (chunkSize <= 0 || (long) chunkSize + offset > int.MaxValue)
{
_logger?.LogError("Invalid chunk size ({chunkSize} for chunk {chunkType}) at offset {offset}. Stopping the parsing...", chunkSize, chunkType, archive.Position);
archive.SetError();
return;
}

if (chunkType == ReplayChunkType.ReplayData && _parseMode > ParseMode.EventsOnly)
{
ReadReplayData(archive, chunkSize);
Expand Down

0 comments on commit 81138ec

Please sign in to comment.