Browse Source

Fix improper memory access

Bug reported in
  http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00009.html

* src/transform.c (parse_transform_expr): Check if re is not empty
before accessing its last byte.
Sergey Poznyakoff 6 years ago
parent
commit
eae48289c0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/transform.c

+ 1 - 1
src/transform.c

@@ -273,7 +273,7 @@ parse_transform_expr (const char *expr)
       USAGE_ERROR ((0, 0, _("Invalid transform expression: %s"), errbuf));
     }
 
-  if (str[0] == '^' || str[strlen (str) - 1] == '$')
+  if (str[0] == '^' || (i > 2 && str[i - 3] == '$'))
     tf->transform_type = transform_first;
 
   free (str);