cloudflare / goflow

The high-scalability sFlow/NetFlow/IPFIX collector used internally at Cloudflare.
BSD 3-Clause "New" or "Revised" License
852 stars 171 forks source link

GoFlow segfaults with bad input #118

Open shruthij28 opened 1 year ago

shruthij28 commented 1 year ago

I was trying to run goflow to capture netflow data and push into Kafka, but I've been running into a segfault:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7d139e]

goroutine 26 [running]:
github.com/cloudflare/goflow/v3/utils.UDPRoutine({0x930fa4, 0x7}, 0xc00009e4e0, 0x1, {0x7fffb2e366be, 0x9}, 0x807, 0x0, {0x9e8e38, 0xc00019c000})
    /home/ubuntu/goflow-3.4.4/utils/utils.go:291 +0x75e
github.com/cloudflare/goflow/v3/utils.(*StateNetFlow).FlowRoutine(0xc000074c00, 0x4?, {0x7fffb2e366be, 0x9}, 0xc00020ae70?, 0x0?)
    /home/ubuntu/goflow-3.4.4/utils/netflow.go:358 +0x176
main.main.func2()
    /home/ubuntu/goflow-3.4.4/cmd/goflow/goflow.go:134 +0x1b9
created by main.main
    /home/ubuntu/goflow-3.4.4/cmd/goflow/goflow.go:129 +0x6ad

I've noticed that this is happening when I pass in a value for -nf.port that is already in use; however, I believe that the code should return some sort of error message here instead of just segfaulting.

taktv6 commented 1 year ago

Hi, this issue is fixed in the master branch. I'll try to file a new release asap.

gaby commented 1 year ago

@taktv6 Any chance of getting a new release and updated dependencies?

Thanks!

gaby commented 1 year ago

@taktv6 Any update on this, we currently can't run goflow without doing a clone, and building locally using master. Thanks!