Maximum wait for connection, in seconds (write as a decimal integer
string). Zero or not specified means wait indefinitely. It is not
recommended to use a timeout of less than 2 seconds.
+ This timeout applies separately to each connection attempt.
+ For example, if you specify two hosts and both of them are unreachable,
+ and <literal>connect_timeout</> is 5, the total time spent waiting for a
+ connection might be up to 10 seconds.
</para>
</listitem>
</varlistentry>
min_stat;
int maxlen;
gss_buffer_desc temp_gbuf;
+ char *host = PQhost(conn);
- if (!(conn->pghost && conn->pghost[0] != '\0'))
+ if (!(host && host[0] != '\0'))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("host name must be specified\n"));
return STATUS_ERROR;
}
snprintf(temp_gbuf.value, maxlen, "%s@%s",
- conn->krbsrvname, conn->pghost);
+ conn->krbsrvname, host);
temp_gbuf.length = strlen(temp_gbuf.value);
maj_stat = gss_import_name(&min_stat, &temp_gbuf,
{
SECURITY_STATUS r;
TimeStamp expire;
+ char *host = PQhost(conn);
conn->sspictx = NULL;
* but not more complex. We can skip the @REALM part, because Windows will
* fill that in for us automatically.
*/
- if (!(conn->pghost && conn->pghost[0] != '\0'))
+ if (!(host && host[0] != '\0'))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("host name must be specified\n"));
return STATUS_ERROR;
}
- conn->sspitarget = malloc(strlen(conn->krbsrvname) + strlen(conn->pghost) + 2);
+ conn->sspitarget = malloc(strlen(conn->krbsrvname) + strlen(host) + 2);
if (!conn->sspitarget)
{
printfPQExpBuffer(&conn->errorMessage, libpq_gettext("out of memory\n"));
return STATUS_ERROR;
}
- sprintf(conn->sspitarget, "%s/%s", conn->krbsrvname, conn->pghost);
+ sprintf(conn->sspitarget, "%s/%s", conn->krbsrvname, host);
/*
* Indicate that we're in SSPI authentication mode to make sure that
{
int prefix_len;
char *p;
- char *buf;
+ char *buf = NULL;
char *start;
char prevchar = '\0';
char *user = NULL;
{
printfPQExpBuffer(errorMessage,
libpq_gettext("out of memory\n"));
- return false;
+ goto cleanup;
}
/* need a modifiable copy of the input URI */
{
printfPQExpBuffer(errorMessage,
libpq_gettext("out of memory\n"));
- return false;
+ goto cleanup;
}
start = buf;
cleanup:
termPQExpBuffer(&hostbuf);
termPQExpBuffer(&portbuf);
- free(buf);
+ if (buf)
+ free(buf);
return retval;
}
char *name;
const unsigned char *namedata;
int result;
+ char *host = PQhost(conn);
*store_name = NULL;
return -1;
}
- if (pg_strcasecmp(name, conn->pghost) == 0)
+ if (pg_strcasecmp(name, host) == 0)
{
/* Exact name match */
result = 1;
}
- else if (wildcard_certificate_match(name, conn->pghost))
+ else if (wildcard_certificate_match(name, host))
{
/* Matched wildcard name */
result = 1;
STACK_OF(GENERAL_NAME) *peer_san;
int i;
int rc;
+ char *host = PQhost(conn);
/*
* If told not to verify the peer name, don't do it. Return true
return true;
/* Check that we have a hostname to compare with. */
- if (!(conn->pghost && conn->pghost[0] != '\0'))
+ if (!(host && host[0] != '\0'))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("host name must be specified for a verified SSL connection\n"));
libpq_ngettext("server certificate for \"%s\" (and %d other name) does not match host name \"%s\"\n",
"server certificate for \"%s\" (and %d other names) does not match host name \"%s\"\n",
names_examined - 1),
- first_name, names_examined - 1, conn->pghost);
+ first_name, names_examined - 1, host);
}
else if (names_examined == 1)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("server certificate for \"%s\" does not match host name \"%s\"\n"),
- first_name, conn->pghost);
+ first_name, host);
}
else
{