Fix crash on invalid command line argument

The copy_string_unquote function does not handle arguments which only
consist of a single quote. A string is only quoted if two quoting
characters exist.

How to reproduce:

tar --checkpoint-action exec=\"
This commit is contained in:
Samanta Navarro
2021-06-11 11:52:31 +00:00
committed by Sergey Poznyakoff
parent e5bc23efcc
commit 93082d6eb8

View File

@@ -84,7 +84,7 @@ copy_string_unquote (const char *str)
char *output = xstrdup (str);
size_t len = strlen (output);
if ((*output == '"' || *output == '\'')
&& output[len-1] == *output)
&& len > 1 && output[len-1] == *output)
{
memmove (output, output+1, len-2);
output[len-2] = 0;