Skip to content

ssl.go panics if $HOME is not a directory #609

@nihakue

Description

@nihakue

What is the bug you are experiencing?

When user's $HOME directory is not a directory (e.g. is set to something like /dev/null), lib/pq panics when trying to ping a postgresql database over ssl with the error:
stat /dev/null/.postgresql/postgres.crt is not a directory

How can it be reproduced?

HOME=/dev/null && <try to ping a db using ssl>
Or take a look at this

More Details

This line and other similar checks of if _, err := os.Stat(sslcert); os.IsNotExist(err) result in unexpected behaviour when the 'directory' being looked in is not a directory. os.Stat will return ENOTDIR type error instead of NOTEXIST, and in the case of sslClientCertificates this causes a panic instead of returning early (which is what would happen normally if an sslcert wasn't found).

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