can1357/oh-my-pi · error · ArchiveError

CPIO member '${memberPath}' has an invalid CRC checksum

Error message

CPIO member '${memberPath}' has an invalid CRC checksum

What it means

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.

Source

Thrown at packages/utils/src/ar/cpio.ts:75

	constructor(bytes: Uint8Array, offset: number, size: number, checksum?: number) {
		this.#bytes = bytes;
		this.#offset = offset;
		this.#size = size;
		this.#checksum = checksum;
	}

	async read(size: number, memberPath: string): Promise<Uint8Array> {
		if (size !== this.#size) {
			throw new ArchiveError(`CPIO member '${memberPath}' has an inconsistent declared size`);
		}
		const end = this.#offset + this.#size;
		if (end > this.#bytes.byteLength) {
			throw new ArchiveError(`CPIO member '${memberPath}' is truncated`);
		}
		const bytes = this.#bytes.subarray(this.#offset, end);
		if (this.#checksum !== undefined && checksumBytes(bytes) !== this.#checksum) {
			throw new ArchiveError(`CPIO member '${memberPath}' has an invalid CRC checksum`);
		}
		return bytes;
	}
}

function checksumBytes(bytes: Uint8Array): number {
	let checksum = 0;
	for (const byte of bytes) checksum = (checksum + byte) >>> 0;
	return checksum;
}

function align(value: number, alignment: number): number {
	const remainder = value % alignment;
	return remainder === 0 ? value : value + alignment - remainder;
}

function requireRange(bytes: Uint8Array, start: number, end: number, what: string): void {
	if (

View on GitHub (pinned to 9690622007)

Solutions

  1. Rebuild/re-download the archive and verify against a published hash
  2. Confirm the archive generator computes the checksum correctly (cpio -H newc has a zero checksum; only -H crc fills it)
  3. Check storage/transfer integrity (fsck, checksums after copy)
  4. If corruption is systematic, test with cpio -itv to see which member fails
Defensive patterns

Strategy: validation

Validate before calling

// verify the whole archive before extracting sensitive data
// e.g. compare against a published digest
const digest = new Bun.CryptoHasher('sha256').update(bytes).digest('hex');
if (digest !== EXPECTED_SHA256) throw new Error('cpio failed integrity check before parse');

Try / catch

try {
  const data = await member.read(entry.size, entry.name);
} catch (err) {
  if (err instanceof ArchiveError && /invalid CRC checksum/.test(err.message)) {
    // corrupt member data: quarantine the archive, do not consume output
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Damaged initramfs images; archives transferred over unreliable channels without outer checksums; files stored on failing media; hand-patched cpio data without updating the checksum.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/d838cf3de61178b4. Report an issue: GitHub.