summaryrefslogtreecommitdiffstats
path: root/src/util/sss_tc_utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/sss_tc_utf8.c')
-rw-r--r--src/util/sss_tc_utf8.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util/sss_tc_utf8.c b/src/util/sss_tc_utf8.c
index 6a976211f..e1426a44f 100644
--- a/src/util/sss_tc_utf8.c
+++ b/src/util/sss_tc_utf8.c
@@ -55,3 +55,33 @@ sss_tc_utf8_tolower(TALLOC_CTX *mem_ctx, const uint8_t *s, size_t len, size_t *_
return ret;
}
+errno_t sss_filter_sanitize_for_dom(TALLOC_CTX *mem_ctx,
+ const char *input,
+ struct sss_domain_info *dom,
+ char **sanitized,
+ char **lc_sanitized)
+{
+ int ret;
+
+ ret = sss_filter_sanitize(mem_ctx, input, sanitized);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("sss_filter_sanitize failed.\n"));
+ return ret;
+ }
+
+ if (dom->case_sensitive) {
+ *lc_sanitized = talloc_strdup(mem_ctx, *sanitized);
+ } else {
+ *lc_sanitized = sss_tc_utf8_str_tolower(mem_ctx, *sanitized);
+ }
+
+ if (*lc_sanitized == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("%s failed.\n",
+ dom->case_sensitive ?
+ "talloc_strdup" :
+ "sss_tc_utf8_str_tolower"));
+ return ENOMEM;
+ }
+
+ return EOK;
+}