{"record":{"id":"b606a61f1f118d15","repo":"can1357/oh-my-pi","slug":"invalid-zip-archive-malformed-zip64-extra-field","errorCode":null,"errorMessage":"Invalid ZIP archive: malformed ZIP64 extra field","messagePattern":"Invalid ZIP archive: malformed ZIP64 extra field","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/zip.ts","lineNumber":308,"sourceCode":"\treturn result;\n}\n\nfunction applyZip64Values(\n\textra: Uint8Array | undefined,\n\tcurrent: Zip64Values,\n\tplaceholders: Zip64Placeholders,\n): Zip64Values {\n\tconst needs =\n\t\tplaceholders.uncompressedSize ||\n\t\tplaceholders.compressedSize ||\n\t\tplaceholders.localHeaderOffset ||\n\t\tplaceholders.diskStart;\n\tif (!needs) return current;\n\tif (!extra) throw new ArchiveError(\"Invalid ZIP archive: missing ZIP64 extra field\");\n\tlet offset = 0;\n\tconst result = { ...current };\n\tif (placeholders.uncompressedSize) {\n\t\tif (offset + 8 > extra.byteLength) throw new ArchiveError(\"Invalid ZIP archive: malformed ZIP64 extra field\");\n\t\tresult.uncompressedSize = readUInt64LE(extra, offset);\n\t\toffset += 8;\n\t}\n\tif (placeholders.compressedSize) {\n\t\tif (offset + 8 > extra.byteLength) throw new ArchiveError(\"Invalid ZIP archive: malformed ZIP64 extra field\");\n\t\tresult.compressedSize = readUInt64LE(extra, offset);\n\t\toffset += 8;\n\t}\n\tif (placeholders.localHeaderOffset) {\n\t\tif (offset + 8 > extra.byteLength) throw new ArchiveError(\"Invalid ZIP archive: malformed ZIP64 extra field\");\n\t\tresult.localHeaderOffset = readUInt64LE(extra, offset);\n\t\toffset += 8;\n\t}\n\tif (placeholders.diskStart) {\n\t\tif (offset + 4 > extra.byteLength) throw new ArchiveError(\"Invalid ZIP archive: malformed ZIP64 extra field\");\n\t\tresult.diskStart = readUInt32LE(extra, offset);\n\t}\n\treturn result;","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/zip.ts#L290-L326","documentation":"The ZIP64 extra field (id 0x0001) is present but too short to supply the first required value: the entry needs a 64-bit uncompressed size and the record contains fewer than 8 bytes at the required position. The library validates each field's length before reading and throws rather than returning garbage.","triggerScenarios":"Parsing a ZIP entry with an uncompressedSize placeholder (0xFFFFFFFF) whose 0x0001 extra record data is 1-7 bytes long — a malformed or truncated ZIP64 record.","commonSituations":"Archives produced by non-conformant ZIP64 writers, records truncated by corruption, tools that strip or rewrite extra fields incorrectly, malicious/fuzzed inputs.","solutions":["Verify the archive with unzip -t or 7z t; if corrupt, re-obtain it.","Repack with a standard tool to regenerate correct ZIP64 metadata.","If writing ZIP64 yourself, ensure the 0x0001 record is laid out in the fixed order uncompressed(8) + compressed(8) + offset(8) + disk(4), emitting exactly the fields matching the placeholders."],"exampleFix":"// before: 4-byte zip64 payload for an 8-byte field\n// after\n// const buf = Buffer.alloc(8); buf.writeBigUInt64LE(BigInt(size)); extra = concat(extra, buf);","handlingStrategy":"try-catch","validationCode":"const res = await $`7z t archive.zip`.quiet().nothrow();\nif (res.exitCode !== 0) throw new Error(\"archive failed 7z integrity test\");","typeGuard":null,"tryCatchPattern":"try {\n  await archive.readMember(path);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes(\"malformed ZIP64 extra field\")) {\n    // mark archive as corrupt; fall back to repack with 7z then retry\n  } else throw err;\n}","preventionTips":["Prefer standard archivers (7-Zip, Info-ZIP) when producing >4GB archives.","Verify integrity immediately after download.","Test custom ZIP64 writers against strict parsers before shipping."],"tags":["zip","zip64","archive-corruption"],"backgroundTag":"zip64-malformed-extra-field","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}