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.
This commit is contained in:
Yu Watanabe
2018-02-01 10:11:02 +01:00
committed by Lennart Poettering
parent b9ee05c266
commit e7b2ea7c97
3 changed files with 1 additions and 97 deletions
-36
View File
@@ -393,42 +393,6 @@ char *strv_join(char **l, const char *separator) {
return r;
}
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);
}
int strv_push(char ***l, char *value) {
char **c;
unsigned n, m;
-1
View File
@@ -86,7 +86,6 @@ char **strv_split_newlines(const char *s);
int strv_split_extract(char ***t, const char *s, const char *separators, ExtractFlags flags);
char *strv_join(char **l, const char *separator);
char *strv_join_quoted(char **l);
char **strv_parse_nulstr(const char *s, size_t l);
char **strv_split_nulstr(const char *s);