summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dpkg/tarfn.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 564b4ee24..fff39a534 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -95,26 +95,17 @@ StoC(const char *s, int size)
return str;
}
-/* FIXME: Rewrite using varbuf, once it supports the needed functionality. */
static char *
get_prefix_name(struct tar_header *h)
{
- char *prefix, *name, *s;
+ char *path;
- /* The size is not going to be bigger than that. */
- s = m_malloc(257);
+ path = m_malloc(sizeof(h->prefix) + 1 + sizeof(h->name) + 1);
- prefix = StoC(h->prefix, sizeof(h->prefix));
- name = StoC(h->name, sizeof(h->name));
+ sprintf(path, "%.*s/%.*s", (int)sizeof(h->prefix), h->prefix,
+ (int)sizeof(h->name), h->name);
- strcpy(s, prefix);
- strcat(s, "/");
- strcat(s, name);
-
- free(prefix);
- free(name);
-
- return s;
+ return path;
}
static mode_t