]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix improper memory access
authorSergey Poznyakoff <gray@gnu.org>
Thu, 20 Dec 2018 15:53:40 +0000 (17:53 +0200)
committerSergey Poznyakoff <gray@gnu.org>
Fri, 21 Dec 2018 11:54:11 +0000 (13:54 +0200)
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.

src/transform.c

index 6ef0da6db7a829b68038db27e32c75985994d673..bbf203353df99df47b33aa7a01fcccd11dd237a0 100644 (file)
@@ -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);