Skip to content

nil pointer dereference in endline comment with spaces #52

Open
@dosmanak

Description

@dosmanak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions