{"record":{"id":"7c58077246d8b5df","repo":"can1357/oh-my-pi","slug":"invalid-rar5-utf-8-link-target","errorCode":null,"errorMessage":"Invalid RAR5 UTF-8 link target","messagePattern":"Invalid RAR5 UTF-8 link target","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":404,"sourceCode":"\t\t\t\t\t\t\tneed(extraCursor.offset, 4, extra.end, \"Unix modification time\");\n\t\t\t\t\t\t\tmtimeMs = readUInt32LE(bytes, extraCursor.offset) * 1000;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tneed(extraCursor.offset, 8, extra.end, \"Windows modification time\");\n\t\t\t\t\t\t\tmtimeMs = filetimeMs(bytes, extraCursor.offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (extra.type === 5) {\n\t\t\t\t\tconst redirectionType = readVint(bytes, extraCursor, extra.end, \"redirection type\");\n\t\t\t\t\treadVint(bytes, extraCursor, extra.end, \"redirection flags\");\n\t\t\t\t\tconst targetSize = readVint(bytes, extraCursor, extra.end, \"link target size\");\n\t\t\t\t\tassertArchivePathBytes(targetSize, \"link target\", options.limits.maxPathBytes);\n\t\t\t\t\tneed(extraCursor.offset, targetSize, extra.end, \"link target\");\n\t\t\t\t\tif (redirectionType < 1 || redirectionType > 5)\n\t\t\t\t\t\tthrow new ArchiveError(`Unsupported RAR5 redirection type ${redirectionType}`);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlinkTarget = UTF8.decode(bytes.subarray(extraCursor.offset, extraCursor.offset + targetSize));\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new ArchiveError(\"Invalid RAR5 UTF-8 link target\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (type === 2) {\n\t\t\t\tassertArchiveMemberSize(unpackedSize, rawPath, options.limits);\n\t\t\t\tconst path = normalizeArchiveEntryPath(rawPath);\n\t\t\t\tif (path) {\n\t\t\t\t\tlet linkResolveTarget: boolean | undefined;\n\t\t\t\t\tif (linkTarget !== undefined) {\n\t\t\t\t\t\tconst canonical = canonicalLinkTarget(path, linkTarget);\n\t\t\t\t\t\tlinkTarget = canonical.target;\n\t\t\t\t\t\tlinkResolveTarget = canonical.resolveTarget;\n\t\t\t\t\t}\n\t\t\t\t\tconst isDirectory = (fileFlags & 1) !== 0;\n\t\t\t\t\trecords.push({\n\t\t\t\t\t\tformat: 5,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tdataStart,","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L386-L422","documentation":"The link target stored in a RAR5 redirection extra record (type 5) must be valid UTF-8. When UTF8.decode fails on the target bytes, the library throws this ArchiveError instead of producing a record with a garbled symlink target — indicating corruption or a malformed archive.","triggerScenarios":"A file header contains a redirection extra record whose targetSize bytes fail UTF-8 validation — corrupted archives, wrong extra-record boundaries due to corruption, or crafted/malformed files.","commonSituations":"Damaged downloads; archives edited or re-assembled by broken tooling; fuzzed or malicious archive files; transferring archives in text mode corrupting bytes.","solutions":["Validate the archive with `unrar t` and re-download/re-create if corrupt","Repair with WinRAR's repair or `rar r` if a recovery record exists","Re-create the archive, ensuring symlinks/paths are stored correctly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const records = readRar(bytes);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('Invalid RAR5 UTF-8 link target')) {\n    throw new Error('Archive link metadata is corrupt');\n  } else throw err;\n}","preventionTips":["Verify archive integrity (checksums, `unrar t`) before parsing","Re-create archives whose link records fail validation","Never process archives transferred through lossy/text-mode channels"],"tags":["rar5","utf8","symlink","corruption"],"backgroundTag":"invalid-utf8-path","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}