Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c957ec

Browse files
author
Michael Meskes
committed
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.
1 parent c01bc51 commit 7c957ec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
325325

326326
if (dbname != NULL)
327327
{
328-
/* get the detail information out of dbname */
328+
/* get the detail information from dbname */
329329
if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
330330
{
331331
int offset = 0;
@@ -344,7 +344,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
344344
/*------
345345
* new style:
346346
* <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
347-
* [/db name][?options]
347+
* [/db-name][?options]
348348
*------
349349
*/
350350
offset += strlen("postgresql://");
@@ -427,8 +427,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
427427
}
428428
else
429429
{
430-
host = ecpg_strdup(dbname + offset, lineno);
431-
connect_params++;
430+
if (*(dbname + offset) != '\0')
431+
{
432+
host = ecpg_strdup(dbname + offset, lineno);
433+
connect_params++;
434+
}
432435
}
433436

434437
}

0 commit comments

Comments
 (0)