{"record":{"id":"a26d0f71a54e7f08","repo":"can1357/oh-my-pi","slug":"invalid-rpm-package-tag-tag-data-is-misaligned","errorCode":null,"errorMessage":"Invalid RPM package: tag ${tag} data is misaligned","messagePattern":"Invalid RPM package: tag (.+?) data is misaligned","errorType":"validation","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":112,"sourceCode":"\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} has an invalid count`);\n\t\t\t}\n\t\t\tif (stringCount > remaining) {\n\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} exceeds header data`);\n\t\t\t}\n\t\t\tlet cursor = indexSize + offset;\n\t\t\tconst limit = indexSize + intro.dataSize;\n\t\t\tfor (let stringIndex = 0; stringIndex < stringCount; stringIndex++) {\n\t\t\t\twhile (cursor < limit && body[cursor] !== 0) cursor++;\n\t\t\t\tif (cursor === limit) {\n\t\t\t\t\tthrow new ArchiveError(`Invalid RPM package: string tag ${tag} is not NUL-terminated`);\n\t\t\t\t}\n\t\t\t\tcursor++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} uses unknown data type ${type}`);\n\t\t}\n\t\tif (offset % elementSize !== 0) throw new ArchiveError(`Invalid RPM package: tag ${tag} data is misaligned`);\n\t\tif (count * elementSize > remaining)\n\t\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} exceeds header data`);\n\t}\n}\n\nfunction readHeaderString(\n\tbody: Uint8Array,\n\tindexSize: number,\n\tdataSize: number,\n\toffset: number,\n\tcount: number,\n\ttype: number,\n\ttag: number,\n): string {\n\tif (type !== RPM_TYPE_STRING || count !== 1) {\n\t\tthrow new ArchiveError(`Invalid RPM package: tag ${tag} must contain one string`);\n\t}\n\tconst start = indexSize + offset;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L94-L130","documentation":"Fixed-size numeric RPM tag data (INT16/INT32/INT64) must start at an offset aligned to its element size within the data region. This parser enforces natural alignment before reading multi-byte integers, so a misaligned offset indicates a corrupt or malformed header rather than risking misread values.","triggerScenarios":"readRpm()/parseMainHeader validates an index entry of type 3/4/5 whose offset field is not divisible by the element size (2/4/8) — e.g. an INT32 tag with offset 3.","commonSituations":"Bit-level corruption of the offset field; headers hand-assembled by buggy custom tooling; fuzzed inputs targeting integer-reading paths.","solutions":["Treat the file as corrupt: re-download or rebuild the .rpm package.","Verify with an independent RPM tool to confirm the header is malformed.","If your own build tooling writes the header, fix its offset/alignment bookkeeping (data is stored in tag order with natural alignment).","Catch ArchiveError around readRpm and reject the package gracefully."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const entries = await readRpm(source, options);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"misaligned\")) {\n    return quarantine(file, \"corrupt RPM header alignment\");\n  }\n  throw err;\n}","preventionTips":["Verify package checksums before parsing.","Avoid custom tooling that writes RPM headers manually; use rpmbuild.","Quarantine and report files that fail header validation instead of retrying."],"tags":["rpm","archive","alignment","header-validation"],"backgroundTag":"rpm-header-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}