diff options
author | Michael Meskes <meskes@postgresql.org> | 2014-01-01 12:24:19 +0100 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2014-01-01 12:44:58 +0100 |
commit | 96de4939c0038fecd03f88891538053c691eeebd (patch) | |
tree | d026891556072932e07cc34b482e642500ec96de /src | |
parent | 302cbc5fa6f5927a36bf22b5cfb356c1fe4284a6 (diff) | |
download | postgresql-96de4939c0038fecd03f88891538053c691eeebd.tar.gz postgresql-96de4939c0038fecd03f88891538053c691eeebd.zip |
Do not use an empty hostname.
When trying to connect to a given database libecpg should not try using an
empty hostname if no hostname was given.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 4fe2cf6a445..92d25b6fb4a 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -326,7 +326,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p if (dbname != NULL) { - /* get the detail information out of dbname */ + /* get the detail information from dbname */ if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0) { int offset = 0; @@ -345,7 +345,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p /*------ * new style: * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:] - * [/db name][?options] + * [/db-name][?options] *------ */ offset += strlen("postgresql://"); @@ -420,8 +420,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p } } else - host = ecpg_strdup(dbname + offset, lineno); - + { + if (*(dbname + offset) != '\0') + host = ecpg_strdup(dbname + offset, lineno); + } } } else |