Explorar o código

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 %!s(int64=6) %!d(string=hai) anos
pai
achega
eae48289c0
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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);