can1357/oh-my-pi · error · ArchiveError
Invalid RPM package: corrupt ${what} header reserved bytes
Error message
Invalid RPM package: corrupt ${what} header reserved bytes What it means
ArchiveError thrown by parseHeaderIntro() when bytes 4..8 of an RPM header intro (the reserved field) are non-zero. The RPM format requires these bytes to be zero; non-zero means the header region is malformed.
Source
Thrown at packages/utils/src/ar/rpm.ts:60
const remainder = value % alignment;
return remainder === 0 ? value : value + alignment - remainder;
}
async function readExact(source: ByteSource, start: number, end: number, what: string): Promise<Uint8Array> {
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end < start || end > source.size) {
throw new ArchiveError(`Invalid RPM package: truncated ${what}`);
}
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);View on GitHub (pinned to 9690622007)
Solutions
- Re-download the package and verify against repository checksums
- Rebuild the package with standard tooling (rpmbuild)
- If you generate RPM-like files yourself, zero bytes 4-8 of the header intro
Example fix
// before intro[4] = flags; // custom field stuffed into reserved bytes // after intro[4] = 0; intro[5] = 0; intro[6] = 0; intro[7] = 0; // reserved must stay zero
Defensive patterns
Strategy: try-catch
Validate before calling
// reserved bytes cannot be cheaply checked without parsing; verify file integrity first
if (!(await checksumMatches(path))) throw new Error('rpm failed checksum'); Type guard
null
Try / catch
try {
const rpm = await readRpmArchive(buf);
} catch (err) {
if (err instanceof ArchiveError && err.message.includes('reserved bytes')) {
// reject as non-conformant/corrupt package
} else throw err;
} Prevention
- Only parse RPMs produced by standard tooling
- Verify package checksums/signatures before parsing
- Treat 'reserved bytes' errors as evidence of tampering or corruption
When it happens
Trigger: Signature or main header intro whose reserved bytes were modified — hand-edited packages, corrupted downloads, or a writer that did not zero the reserved area.
Common situations: Repacked or tampered .rpm files, bit-flips from bad storage, files produced by non-conformant tooling.
Related errors
- Invalid RPM package: null tag ${tag} has values
- Invalid RPM package: corrupt ${what} header magic
- Invalid RPM package: tag ${tag} points outside header data
- Invalid RPM package: string tag ${tag} has an invalid count
- Invalid RPM package: string tag ${tag} exceeds header data
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/e446acd5991edc86.
Report an issue: GitHub.