]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-protocol: Allow rfc5952 "[2001:db8::1]:80" ipv6 notation
authorVolker Lendecke <vl@samba.org>
Thu, 23 Dec 2021 10:52:38 +0000 (11:52 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 13 Jan 2022 16:13:38 +0000 (16:13 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14934
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol_util.c

index 0a0998f18477a8b165e4f55ddf1a59ca8f111da6..c5d0eb6480ea41cd27be589e13a01abe8fe0237a 100644 (file)
@@ -240,6 +240,19 @@ static int ip_from_string(const char *str, ctdb_sock_addr *addr)
                static const uint8_t ipv4_mapped_prefix[12] = {
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff
                };
+               size_t len = strlen(str);
+               char s[64];
+
+               len = strlcpy(s, str, sizeof(s));
+               if (len >= sizeof(s)) {
+                       return EINVAL;
+               }
+
+               if ((len >= 2) && (s[0] == '[') && (s[len-1] == ']')) {
+                       s[len-1] = '\0';
+                       str = s+1;
+                       p = strrchr(str, ':');
+               }
 
                ret = ipv6_from_string(str, &addr->ip6);
                if (ret != 0) {