diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2018-07-14 21:03:06 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2018-07-14 21:03:06 +0100 |
commit | 8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch) | |
tree | 7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /dev-libs/libtar/files | |
parent | 30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff) |
gentoo resync : 14.07.2018
Diffstat (limited to 'dev-libs/libtar/files')
-rw-r--r-- | dev-libs/libtar/files/CVE-2013-4420.patch | 94 | ||||
-rw-r--r-- | dev-libs/libtar/files/libtar-1.2.11-free.patch | 22 | ||||
-rw-r--r-- | dev-libs/libtar/files/libtar-1.2.11-impl-dec.patch | 15 | ||||
-rw-r--r-- | dev-libs/libtar/files/libtar-1.2.20-bin-memleaks.patch | 117 | ||||
-rw-r--r-- | dev-libs/libtar/files/libtar-1.2.20-fd-leaks.patch | 98 | ||||
-rw-r--r-- | dev-libs/libtar/files/libtar-1.2.20-tar_open-memleak.patch | 24 |
6 files changed, 370 insertions, 0 deletions
diff --git a/dev-libs/libtar/files/CVE-2013-4420.patch b/dev-libs/libtar/files/CVE-2013-4420.patch new file mode 100644 index 000000000000..833ff7b1dbb3 --- /dev/null +++ b/dev-libs/libtar/files/CVE-2013-4420.patch @@ -0,0 +1,94 @@ +--- a/lib/decode.c 2013-10-09 09:59:44.000000000 -0700 ++++ b/lib/decode.c 2015-07-20 20:57:58.331945962 -0700 +@@ -21,24 +21,55 @@ + # include <string.h> + #endif + ++char * ++safer_name_suffix (char const *file_name) ++{ ++ char const *p, *t; ++ p = t = file_name; ++ while (*p) ++ { ++ if (p[0] == '.' && p[0] == p[1] && p[2] == '/') ++ { ++ p += 3; ++ t = p; ++ } ++ /* advance pointer past the next slash */ ++ while (*p && (p++)[0] != '/'); ++ } ++ ++ if (!*t) ++ { ++ t = "."; ++ } ++ ++ if (t != file_name) ++ { ++ /* TODO: warn somehow that the path was modified */ ++ } ++ return (char*)t; ++} ++ + + /* determine full path name */ + char * + th_get_pathname(TAR *t) + { + static TLS_THREAD char filename[MAXPATHLEN]; ++ char *safer_name; + + if (t->th_buf.gnu_longname) +- return t->th_buf.gnu_longname; ++ return safer_name_suffix(t->th_buf.gnu_longname); ++ ++ safer_name = safer_name_suffix(t->th_buf.name); + + if (t->th_buf.prefix[0] != '\0') + { + snprintf(filename, sizeof(filename), "%.155s/%.100s", +- t->th_buf.prefix, t->th_buf.name); ++ t->th_buf.prefix, safer_name); + return filename; + } + +- snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name); ++ snprintf(filename, sizeof(filename), "%.100s", safer_name); + return filename; + } + +--- a/lib/extract.c 2013-10-09 09:59:44.000000000 -0700 ++++ b/lib/extract.c 2015-07-20 21:00:16.560956122 -0700 +@@ -305,7 +305,7 @@ + linktgt = &lnp[strlen(lnp) + 1]; + } + else +- linktgt = th_get_linkname(t); ++ linktgt = safer_name_suffix(th_get_linkname(t)); + + #ifdef DEBUG + printf(" ==> extracting: %s (link to %s)\n", filename, linktgt); +@@ -343,9 +343,9 @@ + + #ifdef DEBUG + printf(" ==> extracting: %s (symlink to %s)\n", +- filename, th_get_linkname(t)); ++ filename, safer_name_suffix(th_get_linkname(t))); + #endif +- if (symlink(th_get_linkname(t), filename) == -1) ++ if (symlink(safer_name_suffix(th_get_linkname(t)), filename) == -1) + { + #ifdef DEBUG + perror("symlink()"); +--- a/lib/internal.h 2013-10-09 09:59:44.000000000 -0700 ++++ b/lib/internal.h 2015-07-20 21:00:51.258958673 -0700 +@@ -15,6 +15,7 @@ + + #include <libtar.h> + ++char* safer_name_suffix(char const*); + #ifdef TLS + #define TLS_THREAD TLS + #else diff --git a/dev-libs/libtar/files/libtar-1.2.11-free.patch b/dev-libs/libtar/files/libtar-1.2.11-free.patch new file mode 100644 index 000000000000..cb6524e5e5a0 --- /dev/null +++ b/dev-libs/libtar/files/libtar-1.2.11-free.patch @@ -0,0 +1,22 @@ +stdlib.h is required for free() + +--- a/lib/output.c ++++ b/lib/output.c +@@ -20,6 +20,7 @@ + #include <sys/param.h> + + #ifdef STDC_HEADERS ++# include <stdlib.h> + # include <string.h> + #endif + +--- a/lib/wrapper.c ++++ b/lib/wrapper.c +@@ -18,6 +18,7 @@ + #include <errno.h> + + #ifdef STDC_HEADERS ++# include <stdlib.h> + # include <string.h> + #endif + diff --git a/dev-libs/libtar/files/libtar-1.2.11-impl-dec.patch b/dev-libs/libtar/files/libtar-1.2.11-impl-dec.patch new file mode 100644 index 000000000000..ee00f5c1c9f3 --- /dev/null +++ b/dev-libs/libtar/files/libtar-1.2.11-impl-dec.patch @@ -0,0 +1,15 @@ + lib/extract.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/lib/extract.c b/lib/extract.c +index 6bbb801..3ef2fb8 100644 +--- a/lib/extract.c ++++ b/lib/extract.c +@@ -18,6 +18,7 @@ + #include <fcntl.h> + #include <errno.h> + #include <utime.h> ++#include <string.h> + + #ifdef STDC_HEADERS + # include <stdlib.h> diff --git a/dev-libs/libtar/files/libtar-1.2.20-bin-memleaks.patch b/dev-libs/libtar/files/libtar-1.2.20-bin-memleaks.patch new file mode 100644 index 000000000000..b6195da88d97 --- /dev/null +++ b/dev-libs/libtar/files/libtar-1.2.20-bin-memleaks.patch @@ -0,0 +1,117 @@ +From f3c711cf3054ff366a1a3500cdc8c64ecc2d2da6 Mon Sep 17 00:00:00 2001 +From: Huzaifa Sidhpurwala <huzaifas@fedoraproject.org> +Date: Tue, 15 Oct 2013 20:05:04 -0400 +Subject: [PATCH] fix memleaks in libtar sample program + +--- + libtar/libtar.c | 29 ++++++++++++++++++----------- + 1 file changed, 18 insertions(+), 11 deletions(-) + +diff --git a/libtar/libtar.c b/libtar/libtar.c +index bb5644c..23f8741 100644 +--- a/libtar/libtar.c ++++ b/libtar/libtar.c +@@ -253,6 +253,7 @@ extract(char *tarfile, char *rootdir) + if (tar_extract_all(t, rootdir) != 0) + { + fprintf(stderr, "tar_extract_all(): %s\n", strerror(errno)); ++ tar_close(t); + return -1; + } + +@@ -270,12 +271,13 @@ extract(char *tarfile, char *rootdir) + + + void +-usage() ++usage(void *rootdir) + { + printf("Usage: %s [-C rootdir] [-g] [-z] -x|-t filename.tar\n", + progname); + printf(" %s [-C rootdir] [-g] [-z] -c filename.tar ...\n", + progname); ++ free(rootdir); + exit(-1); + } + +@@ -292,6 +294,7 @@ main(int argc, char *argv[]) + int c; + int mode = 0; + libtar_list_t *l; ++ int return_code = -2; + + progname = basename(argv[0]); + +@@ -313,17 +316,17 @@ main(int argc, char *argv[]) + break; + case 'c': + if (mode) +- usage(); ++ usage(rootdir); + mode = MODE_CREATE; + break; + case 'x': + if (mode) +- usage(); ++ usage(rootdir); + mode = MODE_EXTRACT; + break; + case 't': + if (mode) +- usage(); ++ usage(rootdir); + mode = MODE_LIST; + break; + #ifdef HAVE_LIBZ +@@ -332,7 +335,7 @@ main(int argc, char *argv[]) + break; + #endif /* HAVE_LIBZ */ + default: +- usage(); ++ usage(rootdir); + } + + if (!mode || ((argc - optind) < (mode == MODE_CREATE ? 2 : 1))) +@@ -341,7 +344,7 @@ main(int argc, char *argv[]) + printf("argc - optind == %d\tmode == %d\n", argc - optind, + mode); + #endif +- usage(); ++ usage(rootdir); + } + + #ifdef DEBUG +@@ -351,21 +354,25 @@ main(int argc, char *argv[]) + switch (mode) + { + case MODE_EXTRACT: +- return extract(argv[optind], rootdir); ++ return_code = extract(argv[optind], rootdir); ++ break; + case MODE_CREATE: + tarfile = argv[optind]; + l = libtar_list_new(LIST_QUEUE, NULL); + for (c = optind + 1; c < argc; c++) + libtar_list_add(l, argv[c]); +- return create(tarfile, rootdir, l); ++ return_code = create(tarfile, rootdir, l); ++ libtar_list_free(l, NULL); ++ break; + case MODE_LIST: +- return list(argv[optind]); ++ return_code = list(argv[optind]); ++ break; + default: + break; + } + +- /* NOTREACHED */ +- return -2; ++ free(rootdir); ++ return return_code; + } + + +-- +2.10.5.GIT + diff --git a/dev-libs/libtar/files/libtar-1.2.20-fd-leaks.patch b/dev-libs/libtar/files/libtar-1.2.20-fd-leaks.patch new file mode 100644 index 000000000000..816c96925512 --- /dev/null +++ b/dev-libs/libtar/files/libtar-1.2.20-fd-leaks.patch @@ -0,0 +1,98 @@ +From abd0274e6b2f708e9eaa29414b07b3f542cec694 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka <kdudka@redhat.com> +Date: Tue, 15 Oct 2013 19:48:41 -0400 +Subject: [PATCH] fix file descriptor leaks reported by cppcheck + +Bug: https://bugzilla.redhat.com/785760 +--- + lib/append.c | 14 +++++++++----- + lib/extract.c | 4 ++++ + libtar/libtar.c | 3 +++ + 3 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/lib/append.c b/lib/append.c +index e8bd89d..ff58532 100644 +--- a/lib/append.c ++++ b/lib/append.c +@@ -216,6 +216,7 @@ tar_append_regfile(TAR *t, const char *realname) + int filefd; + int i, j; + size_t size; ++ int rv = -1; + + filefd = open(realname, O_RDONLY); + if (filefd == -1) +@@ -234,25 +235,28 @@ tar_append_regfile(TAR *t, const char *realname) + { + if (j != -1) + errno = EINVAL; +- return -1; ++ goto fail; + } + if (tar_block_write(t, &block) == -1) +- return -1; ++ goto fail; + } + + if (i > 0) + { + j = read(filefd, &block, i); + if (j == -1) +- return -1; ++ goto fail; + memset(&(block[i]), 0, T_BLOCKSIZE - i); + if (tar_block_write(t, &block) == -1) +- return -1; ++ goto fail; + } + ++ /* success! */ ++ rv = 0; ++fail: + close(filefd); + +- return 0; ++ return rv; + } + + +diff --git a/lib/extract.c b/lib/extract.c +index 36357e7..9fc6ad5 100644 +--- a/lib/extract.c ++++ b/lib/extract.c +@@ -228,13 +228,17 @@ tar_extract_regfile(TAR *t, char *realname) + { + if (k != -1) + errno = EINVAL; ++ close(fdout); + return -1; + } + + /* write block to output file */ + if (write(fdout, buf, + ((i > T_BLOCKSIZE) ? T_BLOCKSIZE : i)) == -1) ++ { ++ close(fdout); + return -1; ++ } + } + + /* close output file */ +diff --git a/libtar/libtar.c b/libtar/libtar.c +index 9fa92b2..bb5644c 100644 +--- a/libtar/libtar.c ++++ b/libtar/libtar.c +@@ -83,7 +83,10 @@ gzopen_frontend(char *pathname, int oflags, int mode) + return -1; + + if ((oflags & O_CREAT) && fchmod(fd, mode)) ++ { ++ close(fd); + return -1; ++ } + + gzf = gzdopen(fd, gzoflags); + if (!gzf) +-- +2.10.5.GIT + diff --git a/dev-libs/libtar/files/libtar-1.2.20-tar_open-memleak.patch b/dev-libs/libtar/files/libtar-1.2.20-tar_open-memleak.patch new file mode 100644 index 000000000000..b2a1209f3fc0 --- /dev/null +++ b/dev-libs/libtar/files/libtar-1.2.20-tar_open-memleak.patch @@ -0,0 +1,24 @@ +From 36629a41208375f5105427e98078127551692028 Mon Sep 17 00:00:00 2001 +From: Huzaifa Sidhpurwala <huzaifas@fedoraproject.org> +Date: Tue, 15 Oct 2013 20:02:58 -0400 +Subject: [PATCH] fix memleak on tar_open() failure + +--- + lib/handle.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/handle.c b/lib/handle.c +index 33a262c..002d23c 100644 +--- a/lib/handle.c ++++ b/lib/handle.c +@@ -82,6 +82,7 @@ tar_open(TAR **t, const char *pathname, tartype_t *type, + (*t)->fd = (*((*t)->type->openfunc))(pathname, oflags, mode); + if ((*t)->fd == -1) + { ++ libtar_hash_free((*t)->h, NULL); + free(*t); + return -1; + } +-- +2.10.5.GIT + |