Re: [PATCH v2 1/5] string_helpers: add kstrdup_quotable

From: Joe Perches
Date: Mon Mar 28 2016 - 19:31:26 EST


On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:
> Handle allocating and escaping a string safe for logging.
[]
> diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
[]
> @@ -68,4 +68,6 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
>   return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
>  }
>  
> +char *kstrdup_quotable(char *src);

char *kstrdup_quotable(const char *src)

but shouldn't this really take a gfp_t like all
the other kstr<string> functions?

> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
[]
> +char *kstrdup_quotable(char *src)
[]
> + BUG_ON(string_escape_mem(src, slen, dst, dlen, flags, esc) != dlen);

BUG_ON?  why?