Skip to content

Commit 4f47643

Browse files
Copilotgfs
andcommitted
Improve ACE resource governor check to validate before decompression
Co-authored-by: gfs <98900+gfs@users.noreply.github.com>
1 parent e03db48 commit 4f47643

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

RecursiveExtractor/Extractors/AceExtractor.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ public async IAsyncEnumerable<FileEntry> ExtractAsync(FileEntry fileEntry, Extra
6161
continue;
6262
}
6363

64+
governor.CheckResourceGovernor(entry.Size);
6465
var newFileEntry = await FileEntry.FromStreamAsync(name, aceReader.OpenEntryStream(), fileEntry, entry.CreatedTime, entry.LastModifiedTime, entry.LastAccessedTime, memoryStreamCutoff: options.MemoryStreamCutoff).ConfigureAwait(false);
6566
if (newFileEntry != null)
6667
{
67-
governor.CheckResourceGovernor(newFileEntry.Content.Length);
68-
6968
if (options.Recurse || topLevel)
7069
{
7170
await foreach (var innerEntry in Context.ExtractAsync(newFileEntry, options, governor, false))
@@ -125,6 +124,7 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
125124
FileEntry? newFileEntry = null;
126125
try
127126
{
127+
governor.CheckResourceGovernor(entry.Size);
128128
var stream = aceReader.OpenEntryStream();
129129
var name = entry.Key?.Replace('/', Path.DirectorySeparatorChar);
130130
if (string.IsNullOrEmpty(name))
@@ -140,8 +140,6 @@ public IEnumerable<FileEntry> Extract(FileEntry fileEntry, ExtractorOptions opti
140140
}
141141
if (newFileEntry != null)
142142
{
143-
governor.CheckResourceGovernor(newFileEntry.Content.Length);
144-
145143
if (options.Recurse || topLevel)
146144
{
147145
foreach (var innerEntry in Context.Extract(newFileEntry, options, governor, false))

0 commit comments

Comments
 (0)