Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,18 @@ public void Write([NotNull] byte[] buffer, int offset, int count)

if (ChunkFullyInBuffer())
{
if (BufferedChunkValid())
byte[] bufferHash = _hashFunction(_buffer, 0, (int) Math.Min(_chunksData.ChunkSize, RemainingLength));
byte[] chunkHash = _chunksData.Chunks[_chunkIndex + _startChunk].Hash;

if (BufferedChunkValid(bufferHash, chunkHash))
{
FlushBuffer();
}
else
{
DiscardBuffer();
throw new InvalidChunkDataException("Invalid chunk data.");
throw new InvalidChunkDataException("Invalid chunk data. Expected " +
BitConverter.ToString(chunkHash) + ", got " + BitConverter.ToString(bufferHash));
}
}
} while (count > 0);
Expand All @@ -206,11 +210,8 @@ private bool ChunkFullyInBuffer()
return _bufferPos == Math.Min(_chunksData.ChunkSize, RemainingLength);
}

private bool BufferedChunkValid()
private bool BufferedChunkValid(byte[] bufferHash, byte[] chunkHash)
{
byte[] bufferHash = _hashFunction(_buffer, 0, (int) Math.Min(_chunksData.ChunkSize, RemainingLength));
byte[] chunkHash = _chunksData.Chunks[_chunkIndex + _startChunk].Hash;

return bufferHash.SequenceEqual(chunkHash);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/PatchKit Patcher/Scripts/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public static class Version
public const int Major = 3;
public const int Minor = 17;
public const int Patch = 9;
public const int Hotfix = 2;
public const int Hotfix = 3;

public static string Value
{
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.17.9.3]
### Added
- More information about invalid chunk data exception

## [3.17.9.2]
### Changed
- HDPI scale thresholds
Expand Down