Skip to content

Commit 9484982

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 c41f036 commit 9484982

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/interfaces/ecpg/ecpglib/connect.c

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

325325
if (dbname != NULL)
326326
{
327-
/* get the detail information out of dbname */
327+
/* get the detail information from dbname */
328328
if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
329329
{
330330
int offset = 0;
@@ -343,7 +343,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
343343
/*------
344344
* new style:
345345
* <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
346-
* [/db name][?options]
346+
* [/db-name][?options]
347347
*------
348348
*/
349349
offset += strlen("postgresql://");
@@ -418,8 +418,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
418418
}
419419
}
420420
else
421-
host = ecpg_strdup(dbname + offset, lineno);
422-
421+
{
422+
if (*(dbname + offset) != '\0')
423+
host = ecpg_strdup(dbname + offset, lineno);
424+
}
423425
}
424426
}
425427
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy