diff --git a/backend/files/file-archive.ts b/backend/files/file-archive.ts index 3cc912ed..8f5ba259 100644 --- a/backend/files/file-archive.ts +++ b/backend/files/file-archive.ts @@ -228,8 +228,12 @@ async function extractWithinLimit( failure = new Error(`Extracted content exceeds maximum allowed size of ${limitMB}MB`); return; } - chunks.push(chunk); fileBytes += chunk.length; + if (fileBytes > limit) { + failure = new Error(`Entry "${file.name}" exceeds maximum allowed size of ${limitMB}MB`); + return; + } + chunks.push(chunk); if (final) { writes.push(writeEntry(fullPath, concatChunks(chunks, fileBytes))); entryCount++;