Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when socket_listener receiving invalid data #8551

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

vhqtvn
Copy link
Contributor

@vhqtvn vhqtvn commented Dec 12, 2020

Socket_listener cause Telegraf crash when receiving invalid data if NewStreamContentDecoder returning error. decoder is nil at that time that cause scnr.Scan to dereference null pointer.

E! [inputs.socket_listener] Read error: %vunexpected EOF
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5951da]

goroutine 25 [running]:
bufio.(*Scanner).Scan(0xc000669ec0, 0xbfed4a168ea3030f)
	/usr/local/go/src/bufio/scan.go:214 +0x7a
[global_tags]
github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamSocketListener).read(0xc0005c4800, 0x33d9d80, 0xc000010008)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/socket_listener/socket_listener.go:124 +0x1ae
github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamSocketListener).listen.func1(0xc0001107f0, 0xc0005c4800, 0x33d9d80, 0xc000010008)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/socket_listener/socket_listener.go:74 +0x6b
created by github.com/influxdata/telegraf/plugins/inputs/socket_listener.(*streamSocketListener).listen
	/go/src/github.com/influxdata/telegraf/plugins/inputs/socket_listener/socket_listener.go:72 +0x26b

The fix is easy: just stop when we have an error.

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@ssoroka ssoroka merged commit 8e08da1 into influxdata:master Dec 15, 2020
ssoroka pushed a commit that referenced this pull request Dec 16, 2020
Co-authored-by: Hoa Nguyen Van <[email protected]>
(cherry picked from commit 8e08da1)
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants