Skip to content

Commit

Permalink
Fix nil pointer dereference segfault when passing "null" config json …
Browse files Browse the repository at this point in the history
…to cloudflared tunnel ingress validate (#1070)
  • Loading branch information
samcook authored Dec 14, 2023
1 parent a4a84bb commit f2c4fdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type Ingress struct {

// ParseIngress parses ingress rules, but does not send HTTP requests to the origins.
func ParseIngress(conf *config.Configuration) (Ingress, error) {
if len(conf.Ingress) == 0 {
if conf == nil || len(conf.Ingress) == 0 {
return Ingress{}, ErrNoIngressRules
}
return validateIngress(conf.Ingress, originRequestFromConfig(conf.OriginRequest))
Expand Down
5 changes: 5 additions & 0 deletions ingress/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ ingress:
require.Equal(t, "https", s.scheme)
}

func TestParseIngressNilConfig(t *testing.T) {
_, err := ParseIngress(nil)
require.Error(t, err)
}

func TestParseIngress(t *testing.T) {
localhost8000 := MustParseURL(t, "https://localhost:8000")
localhost8001 := MustParseURL(t, "https://localhost:8001")
Expand Down

0 comments on commit f2c4fdb

Please sign in to comment.