Skip to content

Panic if host is invalid #174

@ukurysheva

Description

@ukurysheva

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions