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

nil pointer dereference in endline comment with spaces #52

Open
dosmanak opened this issue Dec 1, 2022 · 1 comment
Open

nil pointer dereference in endline comment with spaces #52

dosmanak opened this issue Dec 1, 2022 · 1 comment

Comments

@dosmanak
Copy link

dosmanak commented Dec 1, 2022

First of all thank you for your great work folks. 🤗

So I've created haproxy.org/backend-config-snippet and I added a acl line with comment like

acl is_whitelisted src 1.2.3.4  # don't use on production

and I got SIGSEV!

I rolled back config and then tried to reproduce it and the is causing the panic in configParser.

Here's the stacktrace:

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

goroutine 32 [running]:
github.com/haproxytech/config-parser/v4.(*configParser).ProcessLine(_, {_, _}, {_, _, _}, {_, _}, {{}, {0x1b48ae1, ...}, ...})
	/go/pkg/mod/github.com/haproxytech/config-parser/[email protected]/reader.go:155 +0xa24
github.com/haproxytech/config-parser/v4.(*configParser).Process(0xc0000f2840, {0x1d7ee80, 0xc000948990})
	/go/pkg/mod/github.com/haproxytech/config-parser/[email protected]/reader.go:90 +0x61a
github.com/haproxytech/config-parser/v4.New({0xc000776040, 0x1, 0xc000d06420})
	/go/pkg/mod/github.com/haproxytech/config-parser/[email protected]/parser.go:112 +0x1bd
github.com/haproxytech/client-native/v3/configuration.(*client).AddParser(0xc00049bd40, {0xc000d06420, 0x24})
	/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/configuration/configuration.go:131 +0x25f
github.com/haproxytech/client-native/v3/configuration.(*Transaction).startTransaction(0xc00049bd40, 0x3, 0x0)
	/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/configuration/transaction.go:128 +0x2d5
github.com/haproxytech/client-native/v3/configuration.(*Transaction).StartTransaction(0x0, 0xc0017cd330)
	/go/pkg/mod/github.com/haproxytech/client-native/[email protected]/configuration/transaction.go:99 +0x1b
github.com/haproxytech/kubernetes-ingress/pkg/haproxy/api.(*clientNative).APIStartTransaction(0xc000450ba0)
	/src/pkg/haproxy/api/api.go:128 +0x76
github.com/haproxytech/kubernetes-ingress/pkg/controller.(*HAProxyController).clientAPIClosure(0xc000172f00, 0xc0017cd440)
	/src/pkg/controller/controller.go:58 +0x49
github.com/haproxytech/kubernetes-ingress/pkg/controller.(*HAProxyController).setToReady(0xc000172f00)
	/src/pkg/controller/controller.go:177 +0x4f
github.com/haproxytech/kubernetes-ingress/pkg/controller.(*HAProxyController).updateHAProxy(0xc000172f00)
	/src/pkg/controller/controller.go:152 +0x505
github.com/haproxytech/kubernetes-ingress/pkg/controller.(*HAProxyController).SyncData(0xc000172f00)
	/src/pkg/controller/monitor.go:36 +0x457
github.com/haproxytech/kubernetes-ingress/pkg/controller.(*HAProxyController).Start(0xc000172f00)
	/src/pkg/controller/controller.go:81 +0x125
created by main.main
	/src/main.go:118 +0xac5

that led me to

if newState, err := parser.PreParse(line, parts, config.ActiveComments, comment); err == nil {

I know it was rude of me to use such char in a comment especialy in the endline comment, but nevertheless I created this issue.

@dosmanak dosmanak changed the title nil pointer dereference in endline comment with single quote nil pointer dereference in endline comment with spaces Dec 1, 2022
@oktalz
Copy link
Member

oktalz commented Jan 19, 2023

@dosmanak sorry for not responding earlier, this has slipped over my radar

I can reproduce it and will create a fix for it

I know it was rude of me to use such char in a comment especially in the end-line comment, but nevertheless I created this issue.

:D, space or not, one space on end of the comment should not cause a panic for whole application.

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

No branches or pull requests

2 participants