can1357/oh-my-pi · error · ArchiveError
Invalid RPM package: ${what} header is too large
Error message
Invalid RPM package: ${what} header is too large What it means
ArchiveError thrown by parseHeaderIntro() when indexCount * RPM_INDEX_ENTRY_SIZE + dataSize (bodySize) is not a safe integer — the header declares an absurdly large size. After the count is checked against options.limits via assertEntryCount, this catches numeric overflow of the combined body size before any allocation/read.
Source
Thrown at packages/utils/src/ar/rpm.ts:67
}
const bytes = await source.read(start, end);
if (bytes.byteLength !== end - start) throw new ArchiveError(`Invalid RPM package: truncated ${what}`);
return bytes;
}
function parseHeaderIntro(bytes: Uint8Array, options: FormatReadOptions, what: string): HeaderIntro {
if (bytes.byteLength !== RPM_HEADER_INTRO_SIZE || readUInt32BE(bytes, 0) !== RPM_HEADER_MAGIC) {
throw new ArchiveError(`Invalid RPM package: corrupt ${what} header magic`);
}
for (let offset = 4; offset < 8; offset++) {
if (bytes[offset] !== 0) throw new ArchiveError(`Invalid RPM package: corrupt ${what} header reserved bytes`);
}
const indexCount = readUInt32BE(bytes, 8);
const dataSize = readUInt32BE(bytes, 12);
assertEntryCount(indexCount, options.limits);
const indexSize = indexCount * RPM_INDEX_ENTRY_SIZE;
const bodySize = indexSize + dataSize;
if (!Number.isSafeInteger(bodySize)) throw new ArchiveError(`Invalid RPM package: ${what} header is too large`);
assertIndexSize(RPM_HEADER_INTRO_SIZE + bodySize, options.limits, `RPM ${what} header`);
return { indexCount, dataSize, bodySize, totalSize: RPM_HEADER_INTRO_SIZE + bodySize };
}
function validateHeaderBody(body: Uint8Array, intro: HeaderIntro, what: string): void {
const indexSize = intro.indexCount * RPM_INDEX_ENTRY_SIZE;
if (body.byteLength !== intro.bodySize) throw new ArchiveError(`Invalid RPM package: truncated ${what} header`);
for (let index = 0; index < intro.indexCount; index++) {
const recordOffset = index * RPM_INDEX_ENTRY_SIZE;
const tag = readUInt32BE(body, recordOffset);
const type = readUInt32BE(body, recordOffset + 4);
const offset = readUInt32BE(body, recordOffset + 8);
const count = readUInt32BE(body, recordOffset + 12);
if (offset > intro.dataSize) throw new ArchiveError(`Invalid RPM package: tag ${tag} points outside header data`);
const remaining = intro.dataSize - offset;
let elementSize = 0;
if (type === 1 || type === 2 || type === 7) elementSize = 1;
else if (type === 3) elementSize = 2;View on GitHub (pinned to 9690622007)
Solutions
- Re-download the package from a trusted source
- Verify checksums/signatures before parsing untrusted RPMs
- If parsing your own archives, ensure header indexCount/dataSize are within limits
Example fix
// before
await readRpmArchive(untrustedBuffer);
// after
if (!trustedChecksum(untrustedBuffer)) throw new Error('untrusted rpm');
await readRpmArchive(untrustedBuffer); Defensive patterns
Strategy: validation
Validate before calling
if (buf.byteLength > MAX_EXPECTED_RPM_SIZE) throw new Error('rpm implausibly large');
if (!trustedSource(buf)) throw new Error('refusing to parse untrusted rpm'); Type guard
null
Try / catch
try {
const rpm = await readRpmArchive(buf);
} catch (err) {
if (err instanceof ArchiveError && err.message.includes('header is too large')) {
// treat as malformed/malicious input; reject
} else throw err;
} Prevention
- Only parse RPMs from trusted sources; verify signatures
- Pass sane FormatReadOptions limits to the reader
- Cap input file size before parsing untrusted archives
When it happens
Trigger: A corrupt or malicious header declaring indexCount/dataSize values so large their sum exceeds Number.MAX_SAFE_INTEGER; also header sizes exceeding limits enforced by assertIndexSize right after.
Common situations: Maliciously crafted .rpm files (zip-bomb-style headers), corrupted binaries, random bytes that happen to pass the magic check.
Related errors
- Invalid ARJ archive: too many extended headers
- Invalid RPM package: tag ${tag} string is too large
- Invalid CAB archive: CFHEADER reserve area exceeds 60000 byt
- Archive is too large to read safely
- Archive is too large to read in memory (${formatBytes(size)}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/ed9d0f7760c58afc.
Report an issue: GitHub.