samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
184 stars 31 forks source link

Fix IsInNet index out of bounds on invalid mask #115

Closed cronik closed 1 year ago

cronik commented 1 year ago

If an invalid mask parameter is passed to IsInNet a index out of bound panic will occur.

2023/04/21 10:08:48.712397 server.go:3160: http: panic serving 127.0.0.1:63815: runtime error: index out of range [0] with length 0
goroutine 357 [running]:
net/http.(*conn).serve.func1()
    /Users/runner/hostedtoolcache/go/1.17.13/x64/src/net/http/server.go:1802 +0xb9
panic({0x4468780, 0xc00002cb58})
    /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/panic.go:1047 +0x266
github.com/robertkrimen/otto.catchPanic.func1()
    /Users/runner/go/pkg/mod/github.com/robertkrimen/otto@v0.0.0-20211024170158-b87d35c0b86f/error.go:248 +0x3a5
panic({0x4468780, 0xc00002cb58})
    /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/panic.go:1038 +0x215
main.isInNet({0xc0000e4000, 0x0, 0x0, {0x5, {0x447c720, 0xc000390120}}, {0xc00008ea20, 0x3, 0x4}, 0xc000238600})
    /Users/runner/work/alpaca/alpaca/pacrunner.go:141 +0x2fc