mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Fixed CORE-833.
This commit is contained in:
parent
49ebf1b20b
commit
a9348e5766
@ -289,7 +289,7 @@ static int fork(SOCKET, USHORT);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static in_addr get_bind_address();
|
static in_addr get_bind_address();
|
||||||
static in_addr get_host_address(const TEXT *);
|
static in_addr get_host_address(const Firebird::string&);
|
||||||
|
|
||||||
static void copy_p_cnct_repeat_array( p_cnct::p_cnct_repeat* pDest,
|
static void copy_p_cnct_repeat_array( p_cnct::p_cnct_repeat* pDest,
|
||||||
const p_cnct::p_cnct_repeat* pSource,
|
const p_cnct::p_cnct_repeat* pSource,
|
||||||
@ -666,35 +666,32 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
ISC_tcp_setup(ISC_wait, gds__completion_ast);
|
ISC_tcp_setup(ISC_wait, gds__completion_ast);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const TEXT* protocol = NULL;
|
Firebird::string host;
|
||||||
TEXT temp[BUFFER_TINY];
|
Firebird::string protocol;
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
strncpy(temp, name, sizeof(temp));
|
host = name;
|
||||||
temp[sizeof(temp) - 1] = 0;
|
const size_t pos = host.find("/");
|
||||||
for (TEXT* p = temp; *p;) {
|
if (pos != Firebird::string::npos) {
|
||||||
if (*p++ == '/') {
|
protocol = host.substr(pos + 1);
|
||||||
p[-1] = 0;
|
host = host.substr(0, pos);
|
||||||
name = temp;
|
|
||||||
protocol = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name && *name) {
|
if (host.length()) {
|
||||||
if (port->port_connection) {
|
if (port->port_connection) {
|
||||||
ALLR_free(port->port_connection);
|
ALLR_free(port->port_connection);
|
||||||
}
|
}
|
||||||
port->port_connection = REMOTE_make_string(name);
|
port->port_connection = REMOTE_make_string(host.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
name = port->port_host->str_data;
|
host = port->port_host->str_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!protocol) {
|
if (!protocol.length()) {
|
||||||
const unsigned short port2 = Config::getRemoteServicePort();
|
const unsigned short port2 = Config::getRemoteServicePort();
|
||||||
if (port2) {
|
if (port2) {
|
||||||
|
TEXT temp[BUFFER_TINY];
|
||||||
// EKU: since temp is 128 byte long, the port number will always
|
// EKU: since temp is 128 byte long, the port number will always
|
||||||
// fit into the buffer, hence snprintf replaced with sprintf
|
// fit into the buffer, hence snprintf replaced with sprintf
|
||||||
sprintf(temp, "%hu", port2);
|
sprintf(temp, "%hu", port2);
|
||||||
@ -712,13 +709,13 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
/* V M S */
|
/* V M S */
|
||||||
if (getservport(protocol, "tcp", &address.sin_port) == -1) {
|
if (getservport(protocol.c_str(), "tcp", &address.sin_port) == -1) {
|
||||||
inet_error(port, "getservbyname", isc_net_connect_err, 0);
|
inet_error(port, "getservbyname", isc_net_connect_err, 0);
|
||||||
disconnect(port);
|
disconnect(port);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (packet) {
|
if (packet) {
|
||||||
if (getaddr(name, &address) == -1) {
|
if (getaddr(host.c_str(), &address) == -1) {
|
||||||
inet_error(port, "gethostbyname", isc_net_connect_err, 0);
|
inet_error(port, "gethostbyname", isc_net_connect_err, 0);
|
||||||
disconnect(port);
|
disconnect(port);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -739,13 +736,13 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
|
|
||||||
if (packet) {
|
if (packet) {
|
||||||
// client connection
|
// client connection
|
||||||
host_addr = get_host_address(name);
|
host_addr = get_host_address(host);
|
||||||
|
|
||||||
if (host_addr.s_addr == INADDR_NONE)
|
if (host_addr.s_addr == INADDR_NONE)
|
||||||
{
|
{
|
||||||
SNPRINTF(msg, FB_NELEM(msg),
|
SNPRINTF(msg, FB_NELEM(msg),
|
||||||
"INET/INET_connect: gethostbyname (%s) failed, error code = %d",
|
"INET/INET_connect: gethostbyname (%s) failed, error code = %d",
|
||||||
name, H_ERRNO);
|
host.c_str(), H_ERRNO);
|
||||||
gds__log(msg, 0);
|
gds__log(msg, 0);
|
||||||
inet_gen_error(port,
|
inet_gen_error(port,
|
||||||
isc_network_error,
|
isc_network_error,
|
||||||
@ -769,7 +766,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
|
|
||||||
THREAD_EXIT();
|
THREAD_EXIT();
|
||||||
|
|
||||||
const struct servent* service = getservbyname(protocol, "tcp");
|
const struct servent* service = getservbyname(protocol.c_str(), "tcp");
|
||||||
#ifdef WIN_NT
|
#ifdef WIN_NT
|
||||||
/* On Windows NT/9x, getservbyname can only accomodate
|
/* On Windows NT/9x, getservbyname can only accomodate
|
||||||
* 1 call at a time. In this case it returns the error
|
* 1 call at a time. In this case it returns the error
|
||||||
@ -780,7 +777,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
if (!service) {
|
if (!service) {
|
||||||
if (H_ERRNO == INET_RETRY_ERRNO) {
|
if (H_ERRNO == INET_RETRY_ERRNO) {
|
||||||
for (int retry = 0; retry < INET_RETRY_CALL; retry++) {
|
for (int retry = 0; retry < INET_RETRY_CALL; retry++) {
|
||||||
if ( (service = getservbyname(protocol, "tcp")) )
|
if ( (service = getservbyname(protocol.c_str(), "tcp")) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -797,7 +794,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
for zero-installation clients.
|
for zero-installation clients.
|
||||||
*/
|
*/
|
||||||
if (!service) {
|
if (!service) {
|
||||||
if (strcmp(protocol, FB_SERVICE_NAME) == 0) {
|
if (protocol == FB_SERVICE_NAME) {
|
||||||
/* apply hardwired translation */
|
/* apply hardwired translation */
|
||||||
address.sin_port = htons(FB_SERVICE_PORT);
|
address.sin_port = htons(FB_SERVICE_PORT);
|
||||||
}
|
}
|
||||||
@ -808,7 +805,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
* let's see whether this is a port number
|
* let's see whether this is a port number
|
||||||
* instead of a service name
|
* instead of a service name
|
||||||
*/
|
*/
|
||||||
address.sin_port = htons(atoi(protocol));
|
address.sin_port = htons(atoi(protocol.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address.sin_port == 0)
|
if (address.sin_port == 0)
|
||||||
@ -819,6 +816,7 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
"INET/INET_connect: getservbyname failed, error code = %d",
|
"INET/INET_connect: getservbyname failed, error code = %d",
|
||||||
H_ERRNO);
|
H_ERRNO);
|
||||||
gds__log(msg, 0);
|
gds__log(msg, 0);
|
||||||
|
const rem_str* const string = REMOTE_make_string(protocol.c_str());
|
||||||
inet_gen_error(port,
|
inet_gen_error(port,
|
||||||
isc_network_error,
|
isc_network_error,
|
||||||
isc_arg_string,
|
isc_arg_string,
|
||||||
@ -828,7 +826,8 @@ rem_port* INET_connect(const TEXT* name,
|
|||||||
isc_arg_gds,
|
isc_arg_gds,
|
||||||
isc_service_unknown,
|
isc_service_unknown,
|
||||||
isc_arg_string,
|
isc_arg_string,
|
||||||
protocol, isc_arg_string, "tcp", 0);
|
string->str_data,
|
||||||
|
isc_arg_string, "tcp", 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* else / not hardwired gds_db translation */
|
} /* else / not hardwired gds_db translation */
|
||||||
}
|
}
|
||||||
@ -2026,7 +2025,7 @@ static in_addr get_bind_address()
|
|||||||
return config_address;
|
return config_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
static in_addr get_host_address(const TEXT* name)
|
static in_addr get_host_address(const Firebird::string& name)
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
*
|
*
|
||||||
@ -2042,11 +2041,11 @@ static in_addr get_host_address(const TEXT* name)
|
|||||||
|
|
||||||
THREAD_EXIT();
|
THREAD_EXIT();
|
||||||
|
|
||||||
address.s_addr = inet_addr(name);
|
address.s_addr = inet_addr(name.c_str());
|
||||||
|
|
||||||
if (address.s_addr == INADDR_NONE) {
|
if (address.s_addr == INADDR_NONE) {
|
||||||
|
|
||||||
const hostent* host = gethostbyname(name);
|
const hostent* host = gethostbyname(name.c_str());
|
||||||
|
|
||||||
/* On Windows NT/9x, gethostbyname can only accomodate
|
/* On Windows NT/9x, gethostbyname can only accomodate
|
||||||
* 1 call at a time. In this case it returns the error
|
* 1 call at a time. In this case it returns the error
|
||||||
@ -2059,7 +2058,7 @@ static in_addr get_host_address(const TEXT* name)
|
|||||||
if (!host) {
|
if (!host) {
|
||||||
if (H_ERRNO == INET_RETRY_ERRNO) {
|
if (H_ERRNO == INET_RETRY_ERRNO) {
|
||||||
for (int retry = 0; retry < INET_RETRY_CALL; retry++) {
|
for (int retry = 0; retry < INET_RETRY_CALL; retry++) {
|
||||||
if ( (host = gethostbyname(name)) )
|
if ( (host = gethostbyname(name.c_str())) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user