summaryrefslogtreecommitdiff
path: root/archive-tar.c
diff options
context:
space:
mode:
Diffstat (limited to 'archive-tar.c')
-rw-r--r--archive-tar.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/archive-tar.c b/archive-tar.c
index 0ba3f25cf5..719b6298e6 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -153,6 +153,8 @@ static unsigned int ustar_header_chksum(const struct ustar_header *header)
static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)
{
size_t i = pathlen;
+ if (i > 1 && path[i - 1] == '/')
+ i--;
if (i > maxlen)
i = maxlen;
do {
@@ -325,21 +327,13 @@ static struct archiver *find_tar_filter(const char *name, int len)
static int tar_filter_config(const char *var, const char *value, void *data)
{
struct archiver *ar;
- const char *dot;
const char *name;
const char *type;
int namelen;
- if (prefixcmp(var, "tar."))
- return 0;
- dot = strrchr(var, '.');
- if (dot == var + 9)
+ if (parse_config_key(var, "tar", &name, &namelen, &type) < 0 || !name)
return 0;
- name = var + 4;
- namelen = dot - name;
- type = dot + 1;
-
ar = find_tar_filter(name, namelen);
if (!ar) {
ar = xcalloc(1, sizeof(*ar));