{"record":{"id":"d838cf3de61178b4","repo":"can1357/oh-my-pi","slug":"cpio-member-memberpath-has-an-invalid-crc-che","errorCode":null,"errorMessage":"CPIO member '${memberPath}' has an invalid CRC checksum","messagePattern":"CPIO member '(.+?)' has an invalid CRC checksum","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/cpio.ts","lineNumber":75,"sourceCode":"\n\tconstructor(bytes: Uint8Array, offset: number, size: number, checksum?: number) {\n\t\tthis.#bytes = bytes;\n\t\tthis.#offset = offset;\n\t\tthis.#size = size;\n\t\tthis.#checksum = checksum;\n\t}\n\n\tasync read(size: number, memberPath: string): Promise<Uint8Array> {\n\t\tif (size !== this.#size) {\n\t\t\tthrow new ArchiveError(`CPIO member '${memberPath}' has an inconsistent declared size`);\n\t\t}\n\t\tconst end = this.#offset + this.#size;\n\t\tif (end > this.#bytes.byteLength) {\n\t\t\tthrow new ArchiveError(`CPIO member '${memberPath}' is truncated`);\n\t\t}\n\t\tconst bytes = this.#bytes.subarray(this.#offset, end);\n\t\tif (this.#checksum !== undefined && checksumBytes(bytes) !== this.#checksum) {\n\t\t\tthrow new ArchiveError(`CPIO member '${memberPath}' has an invalid CRC checksum`);\n\t\t}\n\t\treturn bytes;\n\t}\n}\n\nfunction checksumBytes(bytes: Uint8Array): number {\n\tlet checksum = 0;\n\tfor (const byte of bytes) checksum = (checksum + byte) >>> 0;\n\treturn checksum;\n}\n\nfunction align(value: number, alignment: number): number {\n\tconst remainder = value % alignment;\n\treturn remainder === 0 ? value : value + alignment - remainder;\n}\n\nfunction requireRange(bytes: Uint8Array, start: number, end: number, what: string): void {\n\tif (","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/cpio.ts#L57-L93","documentation":"Thrown when a CPIO member (newc format with checksum) carries a header checksum that does not match the sum of its data bytes. The data decoded fine but fails the CRC-style integrity check, indicating data corruption.","triggerScenarios":"Reading a corrupted cpio/newc (e.g. SVR4 CRC format) archive where member data was altered in transit or on disk; a generator that wrote the checksum field incorrectly.","commonSituations":"Damaged initramfs images; archives transferred over unreliable channels without outer checksums; files stored on failing media; hand-patched cpio data without updating the checksum.","solutions":["Rebuild/re-download the archive and verify against a published hash","Confirm the archive generator computes the checksum correctly (cpio -H newc has a zero checksum; only -H crc fills it)","Check storage/transfer integrity (fsck, checksums after copy)","If corruption is systematic, test with cpio -itv to see which member fails"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the whole archive before extracting sensitive data\n// e.g. compare against a published digest\nconst digest = new Bun.CryptoHasher('sha256').update(bytes).digest('hex');\nif (digest !== EXPECTED_SHA256) throw new Error('cpio failed integrity check before parse');","typeGuard":null,"tryCatchPattern":"try {\n  const data = await member.read(entry.size, entry.name);\n} catch (err) {\n  if (err instanceof ArchiveError && /invalid CRC checksum/.test(err.message)) {\n    // corrupt member data: quarantine the archive, do not consume output\n  } else throw err;\n}","preventionTips":["Verify archive hashes from the publisher before extraction","Rebuild archives that were transferred without integrity protection","For untrusted input, treat CRC failure as a hard stop, not a warning"],"tags":["cpio","archive","checksum","corruption"],"backgroundTag":"archive-checksum-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}