mirror of
https://github.com/hexchat/hexchat.git
synced 2024-11-13 22:53:45 +01:00
Fix handling invalid ports.
Instead of wrapping around, which is not behaviour any reasonable user would expect, just use the default port if above 65535. Disallow connecting on port 0. This port has special meaning and servers can not listen on it. It is more likely the user just gave an invalid value to the port field as atoi("invalid") == 0.
This commit is contained in:
parent
9c7109b578
commit
91adfb5917
@ -1559,7 +1559,7 @@ server_connect (server *serv, char *hostname, int port, int no_login)
|
|||||||
if (!hostname[0])
|
if (!hostname[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (port < 0)
|
if (port < 1 || port > 65535)
|
||||||
{
|
{
|
||||||
/* use default port for this server type */
|
/* use default port for this server type */
|
||||||
port = 6667;
|
port = 6667;
|
||||||
@ -1568,7 +1568,6 @@ server_connect (server *serv, char *hostname, int port, int no_login)
|
|||||||
port = 6697;
|
port = 6697;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
port &= 0xffff; /* wrap around */
|
|
||||||
|
|
||||||
if (serv->connected || serv->connecting || serv->recondelay_tag)
|
if (serv->connected || serv->connecting || serv->recondelay_tag)
|
||||||
server_disconnect (sess, TRUE, -1);
|
server_disconnect (sess, TRUE, -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user