Skip to content

Commit 2a40dfb

Browse files
committed
Bugfixes and cleanu
* Fixed boundary calculation errors for odd-sized vhdx images * Fixed parameter name mistake with ArgumentOutOfRangeException
1 parent 97c2a9a commit 2a40dfb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Library/DiscUtils.Vhdx/ContentStream.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,17 @@ protected override void Dispose(bool disposing)
606606
private IEnumerable<StreamExtent> GetExtentsRaw(long start, long count)
607607
{
608608
var chunkSize = (1L << 23) * _metadata.LogicalSectorSize;
609-
var chunkRatio = (int)(chunkSize / _metadata.FileParameters.BlockSize);
610609

611610
var pos = MathUtilities.RoundDown(start, chunkSize);
612611

613612
while (pos < start + count)
614613
{
615614
var chunk = GetChunk(pos, out _, out _, out _);
616615

616+
var thisChunkSize = Math.Min(chunkSize, start + count - pos);
617+
618+
var chunkRatio = (int)(thisChunkSize / _metadata.FileParameters.BlockSize);
619+
617620
for (var i = 0; i < chunkRatio; ++i)
618621
{
619622
switch (chunk.GetBlockStatus(i))

Library/DiscUtils.Vhdx/FreeSpaceTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private void ValidateRange(long start, long length, string method)
128128

129129
if (start < 0 || start > _fileSize || length > _fileSize - start)
130130
{
131-
throw new ArgumentOutOfRangeException($"Attempt to {method} space outside of file range");
131+
throw new ArgumentOutOfRangeException(nameof(start), $"Attempt to {method} space outside of file range");
132132
}
133133
}
134134
}

0 commit comments

Comments
 (0)