{"record":{"id":"121de1b6b5205fc8","repo":"can1357/oh-my-pi","slug":"invalid-cab-archive-mszip-block-is-missing-its-ck","errorCode":null,"errorMessage":"Invalid CAB archive: MSZIP block is missing its CK signature","messagePattern":"Invalid CAB archive: MSZIP block is missing its CK signature","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/cab.ts","lineNumber":191,"sourceCode":"\t\tconst output = new Uint8Array(outputSize);\n\t\tconst lzx = description.method === 3 ? new LzxDecoder(description.parameter) : undefined;\n\t\tposition = 0;\n\t\tlet outputPosition = 0;\n\t\tfor (let block = 0; block < description.blockCount; block++) {\n\t\t\tconst compressed = readUInt16LE(bytes, position + 4);\n\t\t\tconst uncompressed = readUInt16LE(bytes, position + 6);\n\t\t\tconst payloadStart = position + DATA_BLOCK_SIZE + this.#dataReserveSize;\n\t\t\tconst payloadEnd = payloadStart + compressed;\n\t\t\tconst payload = bytes.subarray(payloadStart, payloadEnd);\n\t\t\tlet decoded: Uint8Array;\n\t\t\tif (description.method === 0) {\n\t\t\t\tif (compressed !== uncompressed) {\n\t\t\t\t\tthrow new ArchiveError(\"Invalid CAB archive: uncompressed CFDATA sizes do not match\");\n\t\t\t\t}\n\t\t\t\tdecoded = payload;\n\t\t\t} else if (description.method === 1) {\n\t\t\t\tif (payload.byteLength < 2 || payload[0] !== 0x43 || payload[1] !== 0x4b) {\n\t\t\t\t\tthrow new ArchiveError(\"Invalid CAB archive: MSZIP block is missing its CK signature\");\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst dictionary = output.subarray(Math.max(0, outputPosition - MAX_DATA_OUTPUT), outputPosition);\n\t\t\t\t\tdecoded = new Uint8Array(\n\t\t\t\t\t\tzlib.inflateRawSync(payload.subarray(2), { dictionary, maxOutputLength: uncompressed }),\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ArchiveError(\n\t\t\t\t\t\t`Invalid CAB archive: MSZIP decompression failed${error instanceof Error ? `: ${error.message}` : \"\"}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdecoded = lzx!.decompressFrame(payload, uncompressed);\n\t\t\t}\n\t\t\tif (decoded.byteLength !== uncompressed) {\n\t\t\t\tthrow new ArchiveError(\n\t\t\t\t\t`Invalid CAB archive: CFDATA block ${block} produced ${decoded.byteLength} bytes, expected ${uncompressed}`,\n\t\t\t\t);","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/cab.ts#L173-L209","documentation":"Thrown by CabFolder.#decode when the folder's compression method is 1 (MSZIP) but the block payload does not begin with the two-byte 'CK' (0x43 0x4B) magic signature that the MSZIP format requires before the raw deflate stream. Without it the payload cannot be a valid MSZIP block.","triggerScenarios":"readCab() indexed a method-1 folder whose CFDATA payload is shorter than 2 bytes or does not start with 'CK'; caused by corruption, wrong compression method declared in CFFOLDER, or a non-conforming writer.","commonSituations":"Corrupted downloads; cabinets whose folder compression type field was damaged; files produced by broken third-party archivers.","solutions":["Confirm corruption with `cabextract -t file.cab`; re-download if it fails","Check the CFFOLDER compression type byte — if the data is actually stored or LZX, a corrupted type field can masquerade as MSZIP","Regenerate the cabinet with a standard tool if you control its creation","If cabextract reads it fine, file a reader bug with a minimal repro"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const head = new Uint8Array(await Bun.file(path).slice(0, 4).arrayBuffer());\nif (!sniffCab(head)) throw new Error(`not a CAB archive: ${path}`);\n// deeper structure is validated by the reader itself","typeGuard":null,"tryCatchPattern":"try {\n  await readCab(source, opts);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('missing its CK signature'))\n    throw new Error('Cabinet MSZIP block is corrupt or the compression-type field is damaged.');\n  throw err;\n}","preventionTips":["Verify downloads with hashes before extraction","Re-check the archive with `cabextract -t` when this error appears","Regenerate archives with standard tooling if you control production"],"tags":["archive","cab","mszip","corruption"],"backgroundTag":"archive-structure-invalid","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}