{"record":{"id":"e446acd5991edc86","repo":"can1357/oh-my-pi","slug":"invalid-rpm-package-corrupt-what-header-reserv","errorCode":null,"errorMessage":"Invalid RPM package: corrupt ${what} header reserved bytes","messagePattern":"Invalid RPM package: corrupt (.+?) header reserved bytes","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":60,"sourceCode":"\tconst remainder = value % alignment;\n\treturn remainder === 0 ? value : value + alignment - remainder;\n}\n\nasync function readExact(source: ByteSource, start: number, end: number, what: string): Promise<Uint8Array> {\n\tif (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end < start || end > source.size) {\n\t\tthrow new ArchiveError(`Invalid RPM package: truncated ${what}`);\n\t}\n\tconst bytes = await source.read(start, end);\n\tif (bytes.byteLength !== end - start) throw new ArchiveError(`Invalid RPM package: truncated ${what}`);\n\treturn bytes;\n}\n\nfunction parseHeaderIntro(bytes: Uint8Array, options: FormatReadOptions, what: string): HeaderIntro {\n\tif (bytes.byteLength !== RPM_HEADER_INTRO_SIZE || readUInt32BE(bytes, 0) !== RPM_HEADER_MAGIC) {\n\t\tthrow new ArchiveError(`Invalid RPM package: corrupt ${what} header magic`);\n\t}\n\tfor (let offset = 4; offset < 8; offset++) {\n\t\tif (bytes[offset] !== 0) throw new ArchiveError(`Invalid RPM package: corrupt ${what} header reserved bytes`);\n\t}\n\tconst indexCount = readUInt32BE(bytes, 8);\n\tconst dataSize = readUInt32BE(bytes, 12);\n\tassertEntryCount(indexCount, options.limits);\n\tconst indexSize = indexCount * RPM_INDEX_ENTRY_SIZE;\n\tconst bodySize = indexSize + dataSize;\n\tif (!Number.isSafeInteger(bodySize)) throw new ArchiveError(`Invalid RPM package: ${what} header is too large`);\n\tassertIndexSize(RPM_HEADER_INTRO_SIZE + bodySize, options.limits, `RPM ${what} header`);\n\treturn { indexCount, dataSize, bodySize, totalSize: RPM_HEADER_INTRO_SIZE + bodySize };\n}\n\nfunction validateHeaderBody(body: Uint8Array, intro: HeaderIntro, what: string): void {\n\tconst indexSize = intro.indexCount * RPM_INDEX_ENTRY_SIZE;\n\tif (body.byteLength !== intro.bodySize) throw new ArchiveError(`Invalid RPM package: truncated ${what} header`);\n\tfor (let index = 0; index < intro.indexCount; index++) {\n\t\tconst recordOffset = index * RPM_INDEX_ENTRY_SIZE;\n\t\tconst tag = readUInt32BE(body, recordOffset);\n\t\tconst type = readUInt32BE(body, recordOffset + 4);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"Repacked or tampered .rpm files, bit-flips from bad storage, files produced by non-conformant tooling.","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"],"exampleFix":"// before\nintro[4] = flags; // custom field stuffed into reserved bytes\n// after\nintro[4] = 0; intro[5] = 0; intro[6] = 0; intro[7] = 0; // reserved must stay zero","handlingStrategy":"try-catch","validationCode":"// reserved bytes cannot be cheaply checked without parsing; verify file integrity first\nif (!(await checksumMatches(path))) throw new Error('rpm failed checksum');","typeGuard":"null","tryCatchPattern":"try {\n  const rpm = await readRpmArchive(buf);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('reserved bytes')) {\n    // reject as non-conformant/corrupt package\n  } else throw err;\n}","preventionTips":["Only parse RPMs produced by standard tooling","Verify package checksums/signatures before parsing","Treat 'reserved bytes' errors as evidence of tampering or corruption"],"tags":["rpm","archive","format-validation","corrupt-file"],"backgroundTag":"invalid-file-magic","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}