probelabs/goreplay · error

invalid capture info %+v: capture length > length

Error message

invalid capture info %+v:  capture length > length

What it means

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.

Source

Thrown at internal/capture/dump.go:119

		t = time.Now()
	}
	secs := t.Unix()
	usecs := t.Nanosecond() / w.tsScaler
	binary.LittleEndian.PutUint32(w.buf[0:4], uint32(secs))
	binary.LittleEndian.PutUint32(w.buf[4:8], uint32(usecs))
	binary.LittleEndian.PutUint32(w.buf[8:12], uint32(ci.CaptureLength))
	binary.LittleEndian.PutUint32(w.buf[12:16], uint32(ci.Length))
	_, err := w.w.Write(w.buf[:])
	return err
}

// WritePacket writes the given packet data out to the file.
func (w *Writer) WritePacket(ci gopacket.CaptureInfo, data []byte) error {
	if ci.CaptureLength != len(data) {
		return fmt.Errorf("capture length %d does not match data length %d", ci.CaptureLength, len(data))
	}
	if ci.CaptureLength > ci.Length {
		return fmt.Errorf("invalid capture info %+v:  capture length > length", ci)
	}
	if err := w.writePacketHeader(ci); err != nil {
		return fmt.Errorf("error writing packet header: %v", err)
	}
	_, err := w.w.Write(data)
	return err
}

View on GitHub (pinned to 251e45abd2)

Solutions

  1. Audit code that constructs gopacket.CaptureInfo so CaptureLength <= Length
  2. Check for integer truncation or wrong snaplen bookkeeping upstream
  3. Drop the malformed packet rather than persisting a corrupt record
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/capture/dump.go:119 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of probelabs/goreplay@251e45abd2 (2026-09-02). Data as JSON: /api/errors/588596781c3cc28e. Report an issue: GitHub.