[SSSD] [PATCH] failover: Protect against empty host names
Pavel Březina
pbrezina at redhat.com
Tue Oct 16 09:36:32 UTC 2012
On 10/15/2012 12:30 PM, Michal Židek wrote:
> Added new parameter to split_on_separator that allows to skip
> empty values.
>
> https://fedorahosted.org/sssd/ticket/1484
>
> Patch is in attachment.
>
> Michal
Nack. See below.
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -31,7 +31,8 @@
> * the separator is a string, and is case-sensitive.
> * optionally single values can be trimmed of of spaces and tabs */
> int split_on_separator(TALLOC_CTX *mem_ctx, const char *str,
> - const char sep, bool trim, char ***_list, int *size)
> + const char sep, bool trim, bool skip_empty,
> + char ***_list, int *size)
> {
> const char *t, *p, *n;
> size_t l, len;
> @@ -80,6 +81,11 @@ int split_on_separator(TALLOC_CTX *mem_ctx, const char *str,
> }
>
> if (len == 0) {
> + if (skip_empty) {
> + /* Move to next string and continue */
> + t = n;
> + continue;
> + }
Move this^ condition before talloc_realloc.
Handling last element should be rewritten so we treat it the same way as
all previous elements i.e. trim, check if we will put the element in,
realloc, strdup.
More information about the sssd-devel
mailing list