summaryrefslogtreecommitdiffstats
path: root/src/util/util.c
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2012-08-22 15:16:26 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-08-23 18:33:39 +0200
commitb096321a5a02dda0b6b71ba0f9c4d8feacd979e4 (patch)
tree2c540d0dfdf7a4f84d052f85d9b8e519bf8ebc6a /src/util/util.c
parent21d485184df986e1a123f70c689517386e51a5ce (diff)
downloadsssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.gz
sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.xz
sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.zip
Fix: IPv6 address with square brackets doesn't work.
https://fedorahosted.org/sssd/ticket/1365
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index f1aaebc28..b812ef1b1 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -611,3 +611,26 @@ void to_sized_string(struct sized_string *out, const char *in)
}
}
+/* This function only removes first and last
+ * character if the first character was '['.
+ *
+ * NOTE: This means, that ipv6addr must NOT be followed
+ * by port number.
+ */
+errno_t
+remove_ipv6_brackets(char *ipv6addr)
+{
+ size_t len;
+
+ if (ipv6addr && ipv6addr[0] == '[') {
+ len = strlen(ipv6addr);
+ if (len < 3) {
+ return EINVAL;
+ }
+
+ memmove(ipv6addr, &ipv6addr[1], len - 2);
+ ipv6addr[len -2] = '\0';
+ }
+
+ return EOK;
+}