aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2014-01-01 12:24:19 +0100
committerMichael Meskes <meskes@postgresql.org>2014-01-01 12:39:31 +0100
commit7c957ec83eeefa8b6d3179f3af0a5dc338d2252b (patch)
tree71f5559b37b570612e3ca30e90a9c57979ad2646
parentc01bc51f8d596d425d897c833ef11ca3670ea984 (diff)
downloadpostgresql-7c957ec83eeefa8b6d3179f3af0a5dc338d2252b.tar.gz
postgresql-7c957ec83eeefa8b6d3179f3af0a5dc338d2252b.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.
-rw-r--r--src/interfaces/ecpg/ecpglib/connect.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 49f2d546bbe..55c56807b2f 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -325,7 +325,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;
@@ -344,7 +344,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://");
@@ -427,8 +427,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
else
{
- host = ecpg_strdup(dbname + offset, lineno);
- connect_params++;
+ if (*(dbname + offset) != '\0')
+ {
+ host = ecpg_strdup(dbname + offset, lineno);
+ connect_params++;
+ }
}
}