{"record":{"id":"c429d09a3dfb65ac","repo":"txthinking/brook","slug":"data-too-small","errorCode":null,"errorMessage":"data too small","messagePattern":"data too small","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packetserverconn.go","lineNumber":48,"sourceCode":"\t\"github.com/txthinking/x\"\n\t\"golang.org/x/crypto/hkdf\"\n)\n\ntype PacketServerConnFactory struct {\n\tConns map[string]*PacketConn\n\tLock  *sync.Mutex\n}\n\nfunc NewPacketServerConnFactory() *PacketServerConnFactory {\n\treturn &PacketServerConnFactory{\n\t\tConns: make(map[string]*PacketConn),\n\t\tLock:  &sync.Mutex{},\n\t}\n}\n\nfunc (f *PacketServerConnFactory) Handle(addr *net.UDPAddr, b, p []byte, w func([]byte) (int, error), timeout int) (net.Conn, []byte, error) {\n\tif len(b) < 12+4+16 {\n\t\treturn nil, nil, errors.New(\"data too small\")\n\t}\n\tck := x.BP32.Get().([]byte)\n\tif _, err := io.ReadFull(hkdf.New(sha256.New, p, b[:12], ClientHKDFInfo), ck); err != nil {\n\t\tx.BP32.Put(ck)\n\t\treturn nil, nil, err\n\t}\n\n\tcb, err := aes.NewCipher(ck)\n\tif err != nil {\n\t\tx.BP32.Put(ck)\n\t\treturn nil, nil, err\n\t}\n\tx.BP32.Put(ck)\n\tca, err := cipher.NewGCM(cb)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif _, err := ca.Open(b[:12], b[:12], b[12:], nil); err != nil {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/packetserverconn.go#L30-L66","documentation":"Length validation in PacketServerConnFactory.Handle: the first UDP packet from a client is shorter than the 12+4+16 byte minimum needed for the protocol header (salt/nonce plus encrypted fixed fields plus GCM tag), so it cannot be a legitimate brook packet and is discarded. Typically caused by stray traffic, port scans, or a non-brook client hitting the packet server port.","triggerScenarios":"Thrown at packetserverconn.go:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the client is a compatible brook version speaking the packet protocol","Confirm the traffic is actually addressed to the brook UDP port (scans/noise also trigger this)","If legitimate packets are truncated, check for middleboxes fragmenting or clipping UDP payloads"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}