Caddy: slice bounds out of range

Created on 14 Aug 2019  路  9Comments  路  Source: caddyserver/caddy

1. Which version of Caddy are you using (caddy -version)?

1.0.2

2. What are you trying to do?

validate the Caddyfile

3. What is your Caddyfile?

:80 {

}

OR

:443 {

}


4. How did you run Caddy (give the full command and describe the execution environment)?

just try to validate the Caddyfile with: caddy -validate -conf /path/to/your/caddyfile

5. Please paste any relevant HTTP request(s) here.

6. What did you expect to see?


Caddyfile is valid

7. What did you see instead (give full error messages and/or log)?

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/caddyserver/caddy/caddyhttp/httpserver.Address.Key(...)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:494
github.com/caddyserver/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc000144c90, 0xc00002a270, 0x27, 0xc00014c180, 0x1, 0x1, 0xc00014c180, 0x1, 0x1, 0x0, ...)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:143 +0x12f5
github.com/caddyserver/caddy.ValidateAndExecuteDirectives(0xd56ca0, 0xc00014b000, 0xc00016e100, 0xc00014b001, 0x0, 0x0)
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddy.go:614 +0x3be
github.com/caddyserver/caddy/caddy/caddymain.Run()
        /Users/matt/Dev/src/github.com/caddyserver/releaser/cmd/release-caddy/buildenv_08-13-1452.612513987/main/vendor/github.com/caddyserver/caddy/caddy/caddymain/run.go:182 +0x90d
main.main()
        main/main.go:11 +0x2e

8. Why is this a bug, and how do you think this should be fixed?


Server doesn't start as expected

9. What are you doing to work around the problem in the meantime?


revert to previous version 1.0.1

bug

Most helpful comment

I found a fix

We used *:80 and other versions of this definition.

Change it to http://*:80. So put the protocol in front of it and caddy will start with version 1.0.2.

This is also in line with the comment attached to the release.

Hope this will help you guys too :)

All 9 comments

Experiencing the same thing

```panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/caddyserver/caddy/caddyhttp/httpserver.Address.Key(...)
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:494
github.com/caddyserver/caddy/caddyhttp/httpserver.(*httpContext).InspectServerBlocks(0xc000031170, 0x7ffe3b639f5c, 0xf, 0xc0001e6100, 0x3, 0x4, 0xc0001e6100, 0x3, 0x4, 0x0, ...)
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddyhttp/httpserver/plugin.go:143 +0x12ee
github.com/caddyserver/caddy.ValidateAndExecuteDirectives(0xea5f00, 0xc00003ad40, 0xc0001fc200, 0xc0001fc200, 0x1, 0xc00000e058)
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:614 +0x3b7
github.com/caddyserver/caddy.startWithListenerFds(0xea5f00, 0xc00003ad40, 0xc0001fc200, 0x0, 0x0, 0x0)
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:516 +0x125
github.com/caddyserver/caddy.Start(0xea5f00, 0xc00003ad40, 0xea5f00, 0xc00003ad40, 0x0)
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy.go:473 +0xea
github.com/caddyserver/caddy/caddy/caddymain.Run()
/tmp/buildenv_08-14-0630.667715477/main/vendor/github.com/caddyserver/caddy/caddy/caddymain/run.go:193 +0x646
main.main()
main/main.go:17 +0x27
```

I have tried 0.0.0.0:80, *:80 and :80. All variations give this error.

Same issue using the docker image.

From the comment with version 1.0.2 release

One minor breaking change in Go 1.12.8 might affect some configurations that use service name in the port of their Caddyfiles, like so: example.com:https - we've smoothed this over so the behavior of Caddy is the same but if you encounter any odd inconsistencies, switch to using numeric ports or proper URL scheme: either https://example.com (recommended) or example.com:443.

I found a fix

We used *:80 and other versions of this definition.

Change it to http://*:80. So put the protocol in front of it and caddy will start with version 1.0.2.

This is also in line with the comment attached to the release.

Hope this will help you guys too :)

Oops, would someone like to contribute a patch? I'll be away from the computer for the next ~6 hours.

I found a fix

We used *:80 and other versions of this definition.

Change it to http://*:80. So put the protocol in front of it and caddy will start with version 1.0.2.

This is also in line with the comment attached to the release.

Hope this will help you guys too :)

Thanks for posting this fix. Was running into the same issue here.

# Old naming scheme produces a runtime error on v1.0.2
name.example.com:80 { }
# Fix
http://name.example.com:80 { }

I've added test cases and pushed a fix at a08ab0c - would you please try that and confirm it works for you and then I will tag another release. Thanks

I confirm that it is now working correctly. Thanks!

Caddy v1.0.3 has this fix. Thanks for the report!

Was this page helpful?
0 / 5 - 0 ratings