]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix crash on invalid command line argument
authorSamanta Navarro <ferivoz@riseup.net>
Fri, 11 Jun 2021 11:52:31 +0000 (11:52 +0000)
committerSergey Poznyakoff <gray@gnu.org>
Thu, 1 Jul 2021 06:52:42 +0000 (09:52 +0300)
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=\"

src/checkpoint.c

index eb12c1c0b6a5407796caef3d5c93c508156a8852..9d4895cc1a0d7e7b7f90fc41610e0c4ab1deb6e5 100644 (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;