[X2Go-Commits] [libx2goclient] 16/132: src/x2goclient-network-ssh.c: switch from inet_pton () to inet_addr () for IPv4 address validation in x2goclient_network_ssh_parse_sockspec_ip ().

git-admin at x2go.org git-admin at x2go.org
Fri Dec 3 15:26:29 CET 2021


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository libx2goclient.

commit 62663ecd8ebd23ceda01558016a3a7f533c1fc77
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri Feb 19 07:02:13 2021 +0100

    src/x2goclient-network-ssh.c: switch from inet_pton () to inet_addr () for IPv4 address validation in x2goclient_network_ssh_parse_sockspec_ip ().
    
    This allows us to actually support arbitrary IPv4 dotted decimal
    notation (i.e., also the "a.b.c", "a.b" and "a" forms in addition to the
    "a.b.c.d" form), including (ironically), non-decimal notations.
---
 src/x2goclient-network-ssh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c
index 31cfa5c..b28dd9d 100644
--- a/src/x2goclient-network-ssh.c
+++ b/src/x2goclient-network-ssh.c
@@ -502,7 +502,6 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
   if (!(int_err)) {
     gboolean is_v6 = FALSE,
              is_v4 = FALSE;
-    char binary_rep[128] = { 0 };
     if (want_v6) {
       /*
        * Check for an IPv6 address.
@@ -523,6 +522,7 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
         filter_work = g_string_new (filter_start);
       }
 
+      char binary_rep[128] = { 0 };
       is_v6 = (1 == inet_pton (AF_INET6, filter_work->str, &binary_rep));
 
       g_string_free (filter_work, TRUE);
@@ -530,7 +530,7 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
     }
     else {
       /* Check for an IPv4 address. */
-      is_v4 = (1 == inet_pton (AF_INET, address->str, &binary_rep));
+      is_v4 = ((in_addr_t)(-1) != inet_addr (address->str));
     }
 
     if (((is_v6) && (want_v6)) || ((is_v4) && (!(want_v6)))) {

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git


More information about the x2go-commits mailing list