Gondwana Game Engine Development (master) - 2.7.0
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
AssetsFileReadLimits.cs
1using ICSharpCode.SharpZipLib.Zip;
2
3namespace Gondwana.Assets;
4
9public sealed record AssetsFileReadLimits(long MaximumEntryBytes, long MaximumTotalBytes, int MaximumEntries = 10_000)
10{
11 internal void Validate(ZipFile archive)
12 {
13 ArgumentOutOfRangeException.ThrowIfNegative(MaximumEntryBytes);
14 ArgumentOutOfRangeException.ThrowIfNegative(MaximumTotalBytes);
15 ArgumentOutOfRangeException.ThrowIfNegative(MaximumEntries);
16
17 if (archive.Count > MaximumEntries)
18 throw new InvalidDataException($"Archive exceeds the {MaximumEntries:N0}-entry read limit.");
19
20 long total = 0;
21
22 foreach (ZipEntry entry in archive)
23 {
24 if (!entry.IsFile)
25 continue;
26
27 if (entry.Size < 0 || entry.Size > MaximumEntryBytes || entry.Size > MaximumTotalBytes - total)
28 throw new InvalidDataException($"Archive entry '{entry.Name}' exceeds the uncompressed read limits.");
29
30 total += entry.Size;
31 }
32 }
33}
record AssetsFileReadLimits(long MaximumEntryBytes, long MaximumTotalBytes, int MaximumEntries=10_000)
Optional bounds for buffering untrusted archives. Normal runtime loads remain unrestricted.