diff options
Diffstat (limited to 'src/util/util.c')
-rw-r--r-- | src/util/util.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/util/util.c b/src/util/util.c index cfd26a58b..782cd026b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -525,13 +525,15 @@ errno_t sss_hash_create(TALLOC_CTX *mem_ctx, unsigned long count, return sss_hash_create_ex(mem_ctx, count, tbl, 0, 0, 0, 0, NULL, NULL); } -errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx, - const char *input, - char **sanitized) +errno_t sss_filter_sanitize_ex(TALLOC_CTX *mem_ctx, + const char *input, + char **sanitized, + const char *ignore) { char *output; size_t i = 0; size_t j = 0; + char *allowed; /* Assume the worst-case. We'll resize it later, once */ output = talloc_array(mem_ctx, char, strlen(input) * 3 + 1); @@ -540,6 +542,19 @@ errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx, } while (input[i]) { + /* Even though this character might have a special meaning, if it's + * expliticly allowed, just copy it and move on + */ + if (ignore == NULL) { + allowed = NULL; + } else { + allowed = strchr(ignore, input[i]); + } + if (allowed) { + output[j++] = input[i++]; + continue; + } + switch(input[i]) { case '\t': output[j++] = '\\'; @@ -587,6 +602,13 @@ errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx, return EOK; } +errno_t sss_filter_sanitize(TALLOC_CTX *mem_ctx, + const char *input, + char **sanitized) +{ + return sss_filter_sanitize_ex(mem_ctx, input, sanitized, NULL); +} + char * sss_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr) { |