f2a78be751
git-svn-id: http://svn.sabayonlinux.org/overlay@1254 d7aec97c-591d-0410-af39-a8856400b30a
115 lines
2.9 KiB
Diff
115 lines
2.9 KiB
Diff
Seems libtar likes to leak memory. Lets plug it.
|
|
|
|
Patch by Per Lidén http://www.fukt.bth.se/~per/
|
|
https://lists.feep.net:8080/pipermail/libtar/index.html
|
|
http://bugs.gentoo.org/show_bug.cgi?id=82858
|
|
|
|
Problem with patch: doesn't appear to be thread safe, but oh well,
|
|
not like the functions are named with _r suffixes ;).
|
|
|
|
--- libtar-1.2.11-orig/lib/decode.c
|
|
+++ libtar-1.2.11/lib/decode.c
|
|
@@ -26,7 +26,7 @@
|
|
char *
|
|
th_get_pathname(TAR *t)
|
|
{
|
|
- char filename[MAXPATHLEN];
|
|
+ static char filename[MAXPATHLEN];
|
|
|
|
if (t->th_buf.gnu_longname)
|
|
return t->th_buf.gnu_longname;
|
|
@@ -35,11 +35,11 @@
|
|
{
|
|
snprintf(filename, sizeof(filename), "%.155s/%.100s",
|
|
t->th_buf.prefix, t->th_buf.name);
|
|
- return strdup(filename);
|
|
+ return filename;
|
|
}
|
|
|
|
snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name);
|
|
- return strdup(filename);
|
|
+ return filename;
|
|
}
|
|
|
|
|
|
--- libtar-1.2.11-orig/lib/extract.c
|
|
+++ libtar-1.2.11/lib/extract.c
|
|
@@ -28,14 +28,6 @@
|
|
#endif
|
|
|
|
|
|
-struct linkname
|
|
-{
|
|
- char ln_save[MAXPATHLEN];
|
|
- char ln_real[MAXPATHLEN];
|
|
-};
|
|
-typedef struct linkname linkname_t;
|
|
-
|
|
-
|
|
static int
|
|
tar_set_file_perms(TAR *t, char *realname)
|
|
{
|
|
@@ -98,7 +90,9 @@
|
|
tar_extract_file(TAR *t, char *realname)
|
|
{
|
|
int i;
|
|
- linkname_t *lnp;
|
|
+ char *lnp;
|
|
+ int pathname_len;
|
|
+ int realname_len;
|
|
|
|
if (t->options & TAR_NOOVERWRITE)
|
|
{
|
|
@@ -137,11 +131,13 @@
|
|
if (i != 0)
|
|
return i;
|
|
|
|
- lnp = (linkname_t *)calloc(1, sizeof(linkname_t));
|
|
+ pathname_len = strlen(th_get_pathname(t)) + 1;
|
|
+ realname_len = strlen(realname) + 1;
|
|
+ lnp = (char *)calloc(1, pathname_len + realname_len);
|
|
if (lnp == NULL)
|
|
return -1;
|
|
- strlcpy(lnp->ln_save, th_get_pathname(t), sizeof(lnp->ln_save));
|
|
- strlcpy(lnp->ln_real, realname, sizeof(lnp->ln_real));
|
|
+ strcpy(&lnp[0], th_get_pathname(t));
|
|
+ strcpy(&lnp[pathname_len], realname);
|
|
#ifdef DEBUG
|
|
printf("tar_extract_file(): calling libtar_hash_add(): key=\"%s\", "
|
|
"value=\"%s\"\n", th_get_pathname(t), realname);
|
|
@@ -288,7 +284,7 @@
|
|
{
|
|
char *filename;
|
|
char *linktgt = NULL;
|
|
- linkname_t *lnp;
|
|
+ char *lnp;
|
|
libtar_hashptr_t hp;
|
|
|
|
if (!TH_ISLNK(t))
|
|
@@ -304,8 +300,8 @@
|
|
if (libtar_hash_getkey(t->h, &hp, th_get_linkname(t),
|
|
(libtar_matchfunc_t)libtar_str_match) != 0)
|
|
{
|
|
- lnp = (linkname_t *)libtar_hashptr_data(&hp);
|
|
- linktgt = lnp->ln_real;
|
|
+ lnp = (char *)libtar_hashptr_data(&hp);
|
|
+ linktgt = &lnp[strlen(lnp) + 1];
|
|
}
|
|
else
|
|
linktgt = th_get_linkname(t);
|
|
--- libtar-1.2.11-orig/lib/libtar.h
|
|
+++ libtar-1.2.11/lib/libtar.h
|
|
@@ -63,9 +63,9 @@
|
|
/***** handle.c ************************************************************/
|
|
|
|
typedef int (*openfunc_t)(const char *, int, ...);
|
|
-typedef int (*closefunc_t)(int);
|
|
-typedef ssize_t (*readfunc_t)(int, void *, size_t);
|
|
-typedef ssize_t (*writefunc_t)(int, const void *, size_t);
|
|
+typedef int (*closefunc_t)(long);
|
|
+typedef ssize_t (*readfunc_t)(long, void *, size_t);
|
|
+typedef ssize_t (*writefunc_t)(long, const void *, size_t);
|
|
|
|
typedef struct
|
|
{
|