fix(artifacts): revalidate iNES source before parsing header

This commit is contained in:
64579525
2026-10-12 16:11:55 +08:00
parent 574f6bb3bd
commit 5ba8b2f6bf
2 changed files with 40 additions and 2 deletions
+2 -1
View File
@@ -45,13 +45,14 @@ export class InesArtifactReader implements ArtifactReader {
const prefix = Buffer.alloc(16);
const { bytesRead } = await this.source.handle.read(prefix, 0, 16, 0);
abortIfNeeded(signal);
// Concurrent source changes take precedence over malformed header diagnostics.
await this.#verifySource();
const parsed = parseInesLayout(
prefix.subarray(0, bytesRead),
this.source.initial.size,
);
if (!parsed.ok) throw new ArtifactReaderFailure("format", parsed.error);
this.#layout = parsed.value;
await this.#verifySource();
this.#entries.clear();
for (const region of parsed.value.regions) {
abortIfNeeded(signal);