{"record":{"id":"588596781c3cc28e","repo":"probelabs/goreplay","slug":"invalid-capture-info-v-capture-length-length","errorCode":null,"errorMessage":"invalid capture info %+v:  capture length > length","messagePattern":"invalid capture info %\\+v:  capture length > length","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/capture/dump.go","lineNumber":119,"sourceCode":"\t\tt = time.Now()\n\t}\n\tsecs := t.Unix()\n\tusecs := t.Nanosecond() / w.tsScaler\n\tbinary.LittleEndian.PutUint32(w.buf[0:4], uint32(secs))\n\tbinary.LittleEndian.PutUint32(w.buf[4:8], uint32(usecs))\n\tbinary.LittleEndian.PutUint32(w.buf[8:12], uint32(ci.CaptureLength))\n\tbinary.LittleEndian.PutUint32(w.buf[12:16], uint32(ci.Length))\n\t_, err := w.w.Write(w.buf[:])\n\treturn err\n}\n\n// WritePacket writes the given packet data out to the file.\nfunc (w *Writer) WritePacket(ci gopacket.CaptureInfo, data []byte) error {\n\tif ci.CaptureLength != len(data) {\n\t\treturn fmt.Errorf(\"capture length %d does not match data length %d\", ci.CaptureLength, len(data))\n\t}\n\tif ci.CaptureLength > ci.Length {\n\t\treturn fmt.Errorf(\"invalid capture info %+v:  capture length > length\", ci)\n\t}\n\tif err := w.writePacketHeader(ci); err != nil {\n\t\treturn fmt.Errorf(\"error writing packet header: %v\", err)\n\t}\n\t_, err := w.w.Write(data)\n\treturn err\n}\n","sourceCodeStart":101,"sourceCodeEnd":127,"githubUrl":"https://github.com/probelabs/goreplay/blob/251e45abd242886bb64ff2b2dc98789556b56330/internal/capture/dump.go#L101-L127","documentation":"Writer.WritePacket rejects CaptureInfo where CaptureLength exceeds the total packet Length — physically impossible in a capture and a sign of corrupt capture info — to keep the emitted pcap file well-formed.","triggerScenarios":"Thrown at internal/capture/dump.go:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Audit code that constructs gopacket.CaptureInfo so CaptureLength <= Length","Check for integer truncation or wrong snaplen bookkeeping upstream","Drop the malformed packet rather than persisting a corrupt record"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"251e45abd242886bb64ff2b2dc98789556b56330","analyzedAt":"2026-09-02T16:44:11.369Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}