summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2021-12-23 11:52:38 +0100
committerJule Anger <janger@samba.org>2022-01-17 09:32:14 +0000
commit6c28c948a493eed8efd0591fd3d52d6779b74f13 (patch)
tree54da1cd7755d31f497c1b6f769adf5777d05d40b /ctdb
parent671dee2bd7dce22835aff1920759ea726e381dc7 (diff)
downloadsamba-6c28c948a493eed8efd0591fd3d52d6779b74f13.tar.gz
ctdb-protocol: Allow rfc5952 "[2001:db8::1]:80" ipv6 notation
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> (cherry picked from commit 224e99804efef960ef4ce2ff2f4f6dced1e74146)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/protocol/protocol_util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index 2d0a6f33038..3eea95a274e 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -240,6 +240,19 @@ static int ip_from_string(const char *str, ctdb_sock_addr *addr)
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) {