calmh / ipfixcat

Convert an IPFIX stream to readable JSON
MIT License
26 stars 3 forks source link

crash on IPFIX + DPI produced by YAF #1

Closed rouge8 closed 10 years ago

rouge8 commented 10 years ago

I created some IPFIX records with yaf:

yaf --live pcap --in en7 --plugin-name=/usr/local/lib/yaf/dpacketplugin.so --applabel --max-payload=1024 --out flows.ipfix

However, they crash ipfixcat:

$ cat flows.ipfix | ~/Desktop/ipfixcat-v0.2.2/ipfixcat > flows-no-dict.json
2013/11/21 17:07:12 ipfixcat v0.2.2
2013/11/21 17:07:12 EOF
2013/11/21 17:07:12 EOF
2013/11/21 17:07:12 EOF
panic: EOF

goroutine 3 [running]:
runtime.panic(0xe6880, 0x2102f0070)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
main.func·001()
    /Users/jb/src/github.com/calmh/ipfixcat/main.go:40 +0xd2
created by main.messagesGenerator
    /Users/jb/src/github.com/calmh/ipfixcat/main.go:62 +0xf6

goroutine 1 [runnable]:
bytes.makeSlice(0x501, 0x0, 0x0, 0x0)
    /usr/local/go/src/pkg/bytes/buffer.go:191 +0x63
bytes.(*Buffer).grow(0x210676370, 0x5, 0x8a9f8)
    /usr/local/go/src/pkg/bytes/buffer.go:99 +0x200
bytes.(*Buffer).WriteString(0x210676370, 0x1144b6, 0x5, 0x0, 0x0, ...)
    /usr/local/go/src/pkg/bytes/buffer.go:136 +0x4b
encoding/json.(*encodeState).string(0x210676370, 0x1144b6, 0x5, 0x0, 0x1, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:857 +0x122
encoding/json.(*structEncoder).encode(0x210305f00, 0x210676370, 0xf65e0, 0x2105cbc40, 0x196, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:588 +0x1f6
encoding/json.*structEncoder.(encoding/json.encode)·fm(0x210676370, 0xf65e0, 0x2105cbc40, 0x196, 0xf6500)
    /usr/local/go/src/pkg/encoding/json/encode.go:604 +0x58
encoding/json.(*arrayEncoder).encode(0x2104f07e0, 0x210676370, 0xbc0c0, 0x21067f188, 0x172, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:693 +0x103
encoding/json.*arrayEncoder.(encoding/json.encode)·fm(0x210676370, 0xbc0c0, 0x21067f188, 0x172, 0x0)
    /usr/local/go/src/pkg/encoding/json/encode.go:700 +0x58
encoding/json.(*sliceEncoder).encode(0x2104f07e8, 0x210676370, 0xbc0c0, 0x21067f188, 0x172, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:670 +0xb5
encoding/json.*sliceEncoder.(encoding/json.encode)·fm(0x210676370, 0xbc0c0, 0x21067f188, 0x172, 0x0)
    /usr/local/go/src/pkg/encoding/json/encode.go:679 +0x58
encoding/json.(*structEncoder).encode(0x210305db0, 0x210676370, 0xf1080, 0x21067f180, 0x192, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:590 +0x277
encoding/json.*structEncoder.(encoding/json.encode)·fm(0x210676370, 0xf1080, 0x21067f180, 0x192, 0x0)
    /usr/local/go/src/pkg/encoding/json/encode.go:604 +0x58
encoding/json.(*encodeState).reflectValue(0x210676370, 0xf1080, 0x21067f180, 0x192)
    /usr/local/go/src/pkg/encoding/json/encode.go:305 +0x71
encoding/json.(*encodeState).marshal(0x210676370, 0xf1080, 0x21067f180, 0x0, 0x0)
    /usr/local/go/src/pkg/encoding/json/encode.go:276 +0xa6
encoding/json.Marshal(0xf1080, 0x21067f180, 0x2105cba00, 0x13, 0x13, ...)
    /usr/local/go/src/pkg/encoding/json/encode.go:132 +0x6c
main.main()
    /Users/jb/src/github.com/calmh/ipfixcat/main.go:118 +0x93e

I've uploaded the IPFIX sample as a gist.

calmh commented 10 years ago

Ah. Yeah. That's not so much it crashing on the stream, as it lacking an end condition and misinterpreting the end of the stream as an error. I'll fix that, thanks.

rouge8 commented 10 years ago

Ah, you're right. I initially ran it on a different file on a different machine and didn't get the extended traceback, so I thought this was a different error.

Thanks!