8040332: fixpath must explicitly quote empty string parameters

Reviewed-by: ihse
This commit is contained in:
Mike Duigou 2014-04-16 09:00:42 -07:00
parent 4acce14c79
commit 813a1a66d2

View File

@ -118,7 +118,7 @@ void append(char **b, size_t *bl, size_t *u, char *add, size_t addlen)
}
/*
* Creates a new string from in where the first occurance of sub is
* Creates a new string from in where the first occurrence of sub is
* replaced by rep.
*/
char *replace_substring(char *in, char *sub, char *rep)
@ -280,6 +280,11 @@ char * quote_arg(char const * in_arg) {
char *current = quoted;
int pass;
if (strlen(in_arg) == 0) {
// empty string? explicitly quote it.
return _strdup("\"\"");
}
if (strpbrk(in_arg, " \t\n\v\r\\\"") == NULL) {
return _strdup(in_arg);
}