From 2fa1d44f25405a9fd74e7b4d6eecaeabc5c055ed Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 1 Feb 2018 18:11:02 +0900 Subject: [PATCH] strv: drop strv_join_quoted() (#8057) The function `strv_join_quoted()` is now not used, and has a bug in the buffer size calculation when the strings needs to escaped, as reported in #8056. So, let's remove the function. Closes #8056. --- src/basic/strv.c | 36 ------------------------------------ src/basic/strv.h | 1 - 2 files changed, 37 deletions(-) diff --git a/src/basic/strv.c b/src/basic/strv.c index 0d46addbc..f3bb6965a 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -398,43 +398,7 @@ char *strv_join(char **l, const char *separator) { } #if 0 /// UNNEEDED by elogind -char *strv_join_quoted(char **l) { - char *buf = NULL; - char **s; - size_t allocated = 0, len = 0; - - STRV_FOREACH(s, l) { - /* assuming here that escaped string cannot be more - * than twice as long, and reserving space for the - * separator and quotes. - */ - _cleanup_free_ char *esc = NULL; - size_t needed; - - if (!GREEDY_REALLOC(buf, allocated, - len + strlen(*s) * 2 + 3)) - goto oom; - - esc = cescape(*s); - if (!esc) - goto oom; - - needed = snprintf(buf + len, allocated - len, "%s\"%s\"", - len > 0 ? " " : "", esc); - assert(needed < allocated - len); - len += needed; - } - - if (!buf) - buf = malloc0(1); - - return buf; - - oom: - return mfree(buf); -} #endif // 0 - int strv_push(char ***l, char *value) { char **c; unsigned n, m; diff --git a/src/basic/strv.h b/src/basic/strv.h index 32cd6ccd5..489be2f77 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -97,7 +97,6 @@ int strv_split_extract(char ***t, const char *s, const char *separators, Extract char *strv_join(char **l, const char *separator); #if 0 /// UNNEEDED by elogind -char *strv_join_quoted(char **l); #endif // 0 char **strv_parse_nulstr(const char *s, size_t l); -- 2.30.2