Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic if host is invalid #174

Open
ukurysheva opened this issue Nov 7, 2023 · 0 comments
Open

Panic if host is invalid #174

ukurysheva opened this issue Nov 7, 2023 · 0 comments

Comments

@ukurysheva
Copy link
Contributor

Hi, noticed that if DSN provided containes invalid sheme, url object returns no error and an empty host. It gives panic in method ensureHavePort(), because there is no check if the address is empty.

My pull request containes length check in method, also added returning error on parsing dsn stage. Plus added some tests :)

Host check + tests #173

The error trace:

panic: runtime error: index out of range [0] with length 0

goroutine 72 [running]:
github.com/mailru/go-clickhouse.ensureHavePort({0x0, 0x0})
        /Users/kurysheva/go/pkg/mod/github.com/mailru/[email protected]/config.go:187 +0x153
github.com/mailru/go-clickhouse.(*Config).url(0xc000240160, 0xc000687990?, 0x0)
        /Users/kurysheva/go/pkg/mod/github.com/mailru/[email protected]/config.go:85 +0x53
github.com/mailru/go-clickhouse.newConn(0xc000240160)
        /Users/kurysheva/go/pkg/mod/github.com/mailru/[email protected]/conn.go:65 +0x18c
github.com/mailru/go-clickhouse.(*chDriver).Open(0x16e28c0?, {0xc000260540?, 0xc?})
        /Users/kurysheva/go/pkg/mod/github.com/mailru/[email protected]/clickhouse.go:22 +0x45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant