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

Partial read from socket #44

Open
jaredcurtis opened this issue Sep 21, 2020 · 0 comments · May be fixed by #45
Open

Partial read from socket #44

jaredcurtis opened this issue Sep 21, 2020 · 0 comments · May be fixed by #45

Comments

@jaredcurtis
Copy link

Description

Hello,

I've found a bug that can cause a panic. I was able to trigger this by having Dataplane API sync map files while another external process was restarting HAProxy. If I was correct in my reading of the code the cause here is that client-native is reading from a socket and the connection is lost when HAProxy restarts. Because the data is not validated as complete it is then returned and failed to be parsed correctly by other functions.

Setup

  1. A process (Dataplane API) using client-native to read from a socket.
  2. A process that restarts HAProxy

Problem

panic: runtime error: index out of range [2] with length 2
 goroutine 503 [running]:
 github.com/haproxytech/client-native/v2/runtime.parseMapEntry(0xc005147871, 0x10, 0xc01, 0xc001a99f80)
     /home/mjuraga/projects/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/runtime/maps.go:171 +0x226
 github.com/haproxytech/client-native/v2/runtime.ParseMapEntries(0xc005112001, 0x35880, 0x1, 0xc005112001, 0x35880, 0x0)
     /home/mjuraga/projects/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/runtime/maps.go:148 +0x10b
 github.com/haproxytech/client-native/v2/runtime.(*SingleRuntime).ShowMapEntries(0xc000c4fe30, 0xc0010f8388, 0x3, 0xc0010f8388, 0x3, 0x0, 0x0, 0x47c762)
     /home/mjuraga/projects/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/runtime/maps.go:133 +0x1ba
 github.com/haproxytech/client-native/v2/runtime.(*Client).ShowMapEntries(0xc002fc3d10, 0xc0010f8388, 0x3, 0x1, 0x1, 0xc0010f8388, 0x3, 0x24)
     /home/mjuraga/projects/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/runtime/runtime_client.go:493 +0x38d
 github.com/haproxytech/dataplaneapi.syncMapFilesToRuntimeEntries(0xc002135920, 0xc001e96fa0)
     /home/mjuraga/projects/haproxytech/release/dataplaneapi/configure_data_plane.go:806 +0x189
 created by github.com/haproxytech/dataplaneapi.syncMaps
     /home/mjuraga/projects/haproxytech/release/dataplaneapi/configure_data_plane.go:788 +0xbe
jaredcurtis added a commit to jaredcurtis/client-native that referenced this issue Sep 21, 2020
It's possible if an external process causes a reload/restart of HAProxy
that the data from the socket will be truncated. If it is not trucated
on a new line then other functions processing the results will have
malformed data and likely cause a panic.

Resolves haproxytech#44
@jaredcurtis jaredcurtis linked a pull request Sep 21, 2020 that will close this issue
jaredcurtis added a commit to jaredcurtis/client-native that referenced this issue Sep 22, 2020
It's possible if an external process causes a reload/restart of HAProxy
that the data from the socket will be truncated. If it is not trucated
on a new line then other functions processing the results will have
malformed data and likely cause a panic.

Resolves haproxytech#44
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 a pull request may close this issue.

1 participant