{"record":{"id":"a2f4fd591f7521f6","repo":"ruvnet/ruflo","slug":"header-length-extends-beyond-buffer","errorCode":null,"errorMessage":"Header length extends beyond buffer","messagePattern":"Header length extends beyond buffer","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-signing.ts","lineNumber":183,"sourceCode":"  headerEnd: number;\n  sectionData: Buffer;\n  footer: Buffer;\n} {\n  if (buf.length < PREAMBLE_SIZE + SHA256_SIZE) {\n    throw new Error('Buffer too small to be a valid RVFA file');\n  }\n\n  const magic = buf.subarray(0, 4).toString('ascii');\n  if (magic !== 'RVFA') {\n    throw new Error(`Invalid RVFA magic: expected \"RVFA\", got \"${magic}\"`);\n  }\n\n  const headerLen = buf.readUInt32LE(8);\n  const headerStart = PREAMBLE_SIZE;\n  const headerEnd = headerStart + headerLen;\n\n  if (headerEnd > buf.length - SHA256_SIZE) {\n    throw new Error('Header length extends beyond buffer');\n  }\n\n  const headerJson = buf.subarray(headerStart, headerEnd).toString('utf-8');\n  let header: Record<string, unknown>;\n  try {\n    header = JSON.parse(headerJson) as Record<string, unknown>;\n  } catch {\n    throw new Error('Failed to parse RVFA header JSON');\n  }\n\n  const footer = buf.subarray(buf.length - SHA256_SIZE);\n  const sectionData = buf.subarray(headerEnd, buf.length - SHA256_SIZE);\n\n  return { header, headerStart, headerEnd, sectionData, footer };\n}\n\n/**\n * Compute the signing digest for an RVFA file.","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-signing.ts#L165-L201","documentation":"Thrown when headerStart + headerLen (the 4-byte length read from the preamble at offset 8) would read past the buffer minus the footer. The preamble's length field is inconsistent with the file size — a corrupt or truncated image.","triggerScenarios":"The declared header length exceeds the available bytes between preamble and footer: truncated file, partial overwrite, or a bit-flip in the length field.","commonSituations":"Partial download; file truncated by a size-limited transfer; producer wrote a wrong length field.","solutions":["Re-acquire the RVFA file from a trusted source.","On the producer side, cross-check the declared header length against actual bytes written.","Treat the image as unrecoverable; do not retry on the same bytes."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const headerLen = buf.readUInt32LE(8);\nif (PREAMBLE_SIZE + headerLen > buf.length - SHA256_SIZE) {\n  throw new Error('RVFA header length inconsistent with file size; image is corrupt or truncated');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate framing lengths before trusting preamble fields.","Do not retry parse on the same corrupt bytes.","On the writer, assert headerLen matches bytes written."],"tags":["rvfa-signing","buffer-bounds","integrity","header"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}