{"record":{"id":"37746f8cee56b538","repo":"can1357/oh-my-pi","slug":"invalid-rpm-package-string-tag-tag-is-not-nul","errorCode":null,"errorMessage":"Invalid RPM package: string tag ${tag} is not NUL-terminated","messagePattern":"Invalid RPM package: string tag (.+?) is not NUL-terminated","errorType":"validation","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rpm.ts","lineNumber":104,"sourceCode":"\t\telse if (type === 4) elementSize = 4;\n\t\telse if (type === 5) elementSize = 8;\n\t\telse if (type === 0) {\n\t\t\tif (count !== 0) throw new ArchiveError(`Invalid RPM package: null tag ${tag} has values`);\n\t\t\tcontinue;\n\t\t} else if (type === RPM_TYPE_STRING || type === 8 || type === 9) {\n\t\t\tconst stringCount = type === RPM_TYPE_STRING ? 1 : count;\n\t\t\tif (type === RPM_TYPE_STRING && count !== 1) {\n\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,","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rpm.ts#L86-L122","documentation":"RPM strings are stored NUL-terminated in the header data region. When scanning a string-family tag's bytes, if the parser reaches the end of the header data without finding a 0 byte, the string is unterminated — the header is malformed. This also protects against reading past the data region into the payload.","triggerScenarios":"readRpm()/parseMainHeader validates a header whose string tag's bytes run from its offset to the very end of the data area with no NUL terminator — e.g. a truncated header where the final string's terminator was cut off.","commonSituations":"Files truncated mid-download (the terminator lives at the end of the data region); corruption flipping the final NUL byte; hand-built headers missing the terminator.","solutions":["Re-download or rebuild the package; the header data region is damaged or truncated.","Compare the file size/checksum against the upstream publish manifest to detect truncation.","Validate with `rpm -qp` outside this library to confirm the file is bad.","Catch ArchiveError and skip/reject the package in your ingestion pipeline."],"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(\"not NUL-terminated\")) {\n    return reject(\"truncated or corrupt RPM header\");\n  }\n  throw err;\n}","preventionTips":["Verify checksums and full file size (Content-Length) before parsing.","Use resumable/verified downloads to avoid partial files.","Test-parse packages at ingest time, before they are needed."],"tags":["rpm","archive","corrupt-file","truncated"],"backgroundTag":"rpm-header-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}