can1357/oh-my-pi · error · ArchiveError

Invalid old-GNU name record

Error message

Invalid old-GNU name record

What it means

Thrown when parsing an old-GNU name record (typeflag 'N') whose line starts with 'Rename ' but lacks the required ' to ' separator between source and target paths. The record format is structurally malformed.

Source

Thrown at packages/utils/src/ar/tar.ts:308

}

function applyOldGnuNameRecords(
	data: Uint8Array,
	entries: Map<string, ArchiveIndexEntry>,
	pendingLinks: Map<ArchiveIndexEntry, PendingTarLink>,
	limits: ArchiveLimits,
): void {
	assertIndexSize(data.byteLength, limits, "old-GNU name metadata");
	const terminator = data.indexOf(0);
	const end = terminator === -1 ? data.byteLength : terminator;
	let start = 0;
	while (start < end) {
		const newline = data.indexOf(0x0a, start);
		const lineEnd = newline === -1 || newline > end ? end : newline;
		const line = data.subarray(start, lineEnd);
		if (bytesMatchAscii(line, 0, "Rename ")) {
			const separator = indexOfAscii(line, " to ", "Rename ".length);
			if (separator === -1) throw new ArchiveError("Invalid old-GNU name record");
			const source = readMetadataPath(line.subarray("Rename ".length, separator), "old-GNU source path", limits);
			const targetEnd = line[line.byteLength - 1] === 0x2f ? line.byteLength - 1 : line.byteLength;
			const target = readMetadataPath(
				line.subarray(separator + " to ".length, targetEnd),
				"old-GNU target path",
				limits,
			);
			renameOldGnuEntries(
				entries,
				pendingLinks,
				normalizeOldGnuName(source, "source path", limits),
				normalizeOldGnuName(target, "target path", limits),
				limits,
			);
		}
		start = lineEnd + 1;
	}
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify archive integrity and re-download or re-extract from the original source.
  2. Re-create the archive with a standard tar tool; modern tar does not emit old-GNU rename records.
  3. Reject untrusted archives that fail this check — it indicates tampering or corruption.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await readTar(bytes, opts);
} catch (e) {
  if (e instanceof ArchiveError && e.message === "Invalid old-GNU name record") {
    throw new Error("Archive old-GNU metadata is corrupt; obtain a clean copy");
  }
  throw e;
}

Prevention

When it happens

Trigger: readTar/readTarEntriesFromBuffer encounters a 'Rename ...' line inside an old-GNU name metadata block where indexOfAscii(line, " to ") returns -1 — e.g. 'Rename foo' with no target.

Common situations: Corrupted archives, truncated metadata blocks, archives from broken writers, or fuzzed input where the ' to ' delimiter bytes were damaged.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/7f566d69fa032346. Report an issue: GitHub.