1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core, relay: make inet_pton() return value checks more strict

inet_pton() can return values < 0.
This commit is contained in:
LuK1337
2023-09-26 17:14:37 +02:00
committed by Sébastien Helleu
parent 360e971b01
commit 8bd4994ccd
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -337,11 +337,11 @@ network_is_ip_address (const char *address)
return 0;
/* valid IPv4? */
if (inet_pton (AF_INET, address, &server_addr.sin_addr))
if (inet_pton (AF_INET, address, &server_addr.sin_addr) == 1)
return 1;
/* valid IPv6? */
if (inet_pton (AF_INET6, address, &server_addr6.sin6_addr))
if (inet_pton (AF_INET6, address, &server_addr6.sin6_addr) == 1)
return 1;
/* not a valid IP address */
+2 -2
View File
@@ -512,7 +512,7 @@ relay_server_create_socket (struct t_relay_server *server)
server_addr6.sin6_addr = in6addr_any;
if (bind_address && bind_address[0])
{
if (!inet_pton (domain, bind_address, &server_addr6.sin6_addr))
if (inet_pton (domain, bind_address, &server_addr6.sin6_addr) != 1)
{
weechat_printf (NULL,
/* TRANSLATORS: second "%s" is "IPv4" or "IPv6" */
@@ -534,7 +534,7 @@ relay_server_create_socket (struct t_relay_server *server)
server_addr.sin_addr.s_addr = INADDR_ANY;
if (bind_address && bind_address[0])
{
if (!inet_pton (domain, bind_address, &server_addr.sin_addr))
if (inet_pton (domain, bind_address, &server_addr.sin_addr) != 1)
{
weechat_printf (NULL,
/* TRANSLATORS: second "%s" is "IPv4" or "IPv6" */