fix(apple): map Intel version-min to simulators; fail truncated cache hashes

This commit is contained in:
morluto
2026-10-08 16:23:05 +08:00
parent 24c8e13909
commit d4ba8f661b
3 changed files with 38 additions and 4 deletions
+15 -2
View File
@@ -552,18 +552,31 @@ export class DyldSharedCache {
): Promise<string> {
const hash = createHash("sha256");
const buffer = Buffer.alloc(HASH_CHUNK_BYTES);
for (let position = 0; position < file.size;) {
let position = 0;
for (;;) {
signal?.throwIfAborted();
if (position >= file.size) break;
const { bytesRead } = await file.handle.read(
buffer,
0,
Math.min(buffer.length, file.size - position),
position,
);
if (bytesRead === 0) break;
// A file truncated after open must not yield the surviving prefix's
// digest as the identity of the recorded size.
if (bytesRead === 0)
throw new ArtifactReaderFailure(
"integrity",
"dyld cache file changed while its digest was read",
);
hash.update(buffer.subarray(0, bytesRead));
position += bytesRead;
}
if (position !== file.size)
throw new ArtifactReaderFailure(
"integrity",
"dyld cache file changed while its digest was read",
);
return hash.digest("hex");
}