@marcel91200 / caddy Mirror · read-only / commits / 6000855c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

Fix panics by disallowing explicitly-defined null modules in config

Matthew Holt committed Jun 26, 2019 at 10:45 UTC 6000855c82fc1bdc5c256480b4161511f91ed703
1 file changed +9
context.go
+9
@@ -100,6 +100,15 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{},
100 }
101 }
102
103 + if val == nil {
104 + // returned module values are almost always type-asserted
105 + // before being used, so a nil value would panic; and there
106 + // is no good reason to explicitly declare null modules in
107 + // a config; it might be because the user is trying to
108 + // achieve a result they aren't expecting, which is a smell
109 + return nil, fmt.Errorf("module value cannot be null")
110 + }
111 +
112 if prov, ok := val.(Provisioner); ok {
113 err := prov.Provision(ctx)
114 if err != nil {