client-native
client-native copied to clipboard
Partial read from socket
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
- A process (Dataplane API) using
client-nativeto read from a socket. - 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