summaryrefslogtreecommitdiff
path: root/src/util
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
parent21d485184df986e1a123f70c689517386e51a5ce (diff)
downloadsssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.gz
sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.tar.bz2
sssd-b096321a5a02dda0b6b71ba0f9c4d8feacd979e4.zip
Fix: IPv6 address with square brackets doesn't work.
https://fedorahosted.org/sssd/ticket/1365
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util.c23
-rw-r--r--src/util/util.h9
2 files changed, 32 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index f1aaebc2..b812ef1b 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;
+}
diff --git a/src/util/util.h b/src/util/util.h
index 7ff91af5..685702fc 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -516,6 +516,15 @@ errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx,
char *
sss_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr);
+/* 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);
+
/* from sss_tc_utf8.c */
char *
sss_tc_utf8_str_tolower(TALLOC_CTX *mem_ctx, const char *s);