{"record":{"id":"8953a7a8ed689053","repo":"can1357/oh-my-pi","slug":"invalid-cab-archive-cfdata-block-block-produce","errorCode":null,"errorMessage":"Invalid CAB archive: CFDATA block ${block} produced ${decoded.byteLength} bytes, expected ${uncompressed}","messagePattern":"Invalid CAB archive: CFDATA block (.+?) produced (.+?) bytes, expected (.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/cab.ts","lineNumber":205,"sourceCode":"\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);\n\t\t\t}\n\t\t\toutput.set(decoded, outputPosition);\n\t\t\toutputPosition += decoded.byteLength;\n\t\t\tposition = payloadEnd;\n\t\t}\n\t\treturn output;\n\t}\n}\n\nclass CabMemberSource implements MemberSource {\n\treadonly #folder: CabFolder;\n\treadonly #offset: number;\n\treadonly #declaredSize: number;\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/cab.ts#L187-L223","documentation":"Thrown by CabFolder.#decode after decompressing a block: the decoder produced a different number of bytes than the block header's cbUncomp promised. Caught for MSZIP (inflate output length) and LZX (decompressFrame) results; stored blocks are size-checked earlier. Guards against decoders silently emitting truncated or oversized data.","triggerScenarios":"readCab() indexed a folder where zlib.inflateRawSync returned fewer/more bytes than uncompressed (bounded by maxOutputLength), or LzxDecoder.decompressFrame returned a frame of unexpected size — corrupt stream or header mismatch.","commonSituations":"Truncated or bit-flipped compressed data; cabinets written by tools that mis-declare cbUncomp; LZX streams with damaged frame headers.","solutions":["Verify the archive with `cabextract -t file.cab` to confirm the file is corrupt","Re-download the archive from its source and compare hashes","If you generate cabinets, ensure cbUncomp exactly equals the uncompressed block size","If independent tools accept the file, report a reader bug (include the file and block index from the message)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const expected = await getExpectedSha256(path);\nif ((await sha256(path)) !== expected) throw new Error('archive hash mismatch before extraction');","typeGuard":null,"tryCatchPattern":"try {\n  await readCab(source, opts);\n} catch (err) {\n  if (err instanceof ArchiveError && /block \\d+ produced \\d+ bytes/.test(err.message))\n    throw new Error(`Decompressed block size mismatch — archive corrupt or mis-declared: ${err.message}`);\n  throw err;\n}","preventionTips":["Verify archive integrity (hash) before extraction","Test archives with cabextract/7-Zip before feeding them to the library","Report persistent failures on known-good files as reader bugs with the block index from the message"],"tags":["archive","cab","decompression","size-mismatch"],"backgroundTag":"decompression-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}