From: Sergey Poznyakoff Date: Thu, 20 Dec 2018 15:53:40 +0000 (+0200) Subject: Fix improper memory access X-Git-Tag: release_1_31~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eae48289c0848c5812644f20dbb1b39fb117a8f6;p=thirdparty%2Ftar.git 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. --- diff --git a/src/transform.c b/src/transform.c index 6ef0da6d..bbf20335 100644 --- a/src/transform.c +++ b/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);