aboutsummaryrefslogtreecommitdiff
path: root/src
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:44:15 +0100
commit9484982740e880318aa18a953608c6242bb71341 (patch)
tree5f4ad761ffe693fc1748b83da2b889ba62de2b52 /src
parentc41f036445f8dff705139a6d0f3727991b4fe964 (diff)
downloadpostgresql-9484982740e880318aa18a953608c6242bb71341.tar.gz
postgresql-9484982740e880318aa18a953608c6242bb71341.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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 997046b38b7..4f5541308e5 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -324,7 +324,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;
@@ -343,7 +343,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://");
@@ -418,8 +418,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