Blame SOURCES/libtar-1.2.11-bz785760.patch

436cf0
From 6595e6491a472bc4e7f81ed7fe2879c67b3873fe Mon Sep 17 00:00:00 2001
436cf0
From: Kamil Dudka <kdudka@redhat.com>
436cf0
Date: Tue, 7 Feb 2012 13:50:55 +0100
436cf0
Subject: [PATCH] libtar - rhbz #785760
436cf0
436cf0
---
436cf0
 lib/append.c    |   14 ++++++++------
436cf0
 lib/extract.c   |    2 ++
436cf0
 libtar/libtar.c |    3 +++
436cf0
 3 files changed, 13 insertions(+), 6 deletions(-)
436cf0
436cf0
diff --git a/lib/append.c b/lib/append.c
436cf0
index 5489168..690202b 100644
436cf0
--- a/lib/append.c
436cf0
+++ b/lib/append.c
436cf0
@@ -216,6 +216,7 @@ tar_append_regfile(TAR *t, char *realname)
436cf0
 	int filefd;
436cf0
 	int i, j;
436cf0
 	size_t size;
436cf0
+	int rv = -1;
436cf0
 
436cf0
 	filefd = open(realname, O_RDONLY);
436cf0
 	if (filefd == -1)
436cf0
@@ -234,25 +235,26 @@ tar_append_regfile(TAR *t, char *realname)
436cf0
 		{
436cf0
 			if (j != -1)
436cf0
 				errno = EINVAL;
436cf0
-			return -1;
436cf0
+			goto fail;
436cf0
 		}
436cf0
 		if (tar_block_write(t, &block) == -1)
436cf0
-			return -1;
436cf0
+			goto fail;
436cf0
 	}
436cf0
 
436cf0
 	if (i > 0)
436cf0
 	{
436cf0
 		j = read(filefd, &block, i);
436cf0
 		if (j == -1)
436cf0
-			return -1;
436cf0
+			goto fail;
436cf0
 		memset(&(block[i]), 0, T_BLOCKSIZE - i);
436cf0
 		if (tar_block_write(t, &block) == -1)
436cf0
-			return -1;
436cf0
+			goto fail;
436cf0
 	}
436cf0
 
436cf0
+	rv = 0;
436cf0
+fail:
436cf0
 	close(filefd);
436cf0
-
436cf0
-	return 0;
436cf0
+	return rv;
436cf0
 }
436cf0
 
436cf0
 
436cf0
diff --git a/lib/extract.c b/lib/extract.c
436cf0
index b783d87..b36d447 100644
436cf0
--- a/lib/extract.c
436cf0
+++ b/lib/extract.c
436cf0
@@ -245,6 +245,7 @@ tar_extract_regfile(TAR *t, char *realname)
436cf0
 		{
436cf0
 			if (k != -1)
436cf0
 				errno = EINVAL;
436cf0
+			close(fdout);
436cf0
 			free (pn);
436cf0
 			return -1;
436cf0
 		}
436cf0
@@ -253,6 +254,7 @@ tar_extract_regfile(TAR *t, char *realname)
436cf0
 		if (write(fdout, buf,
436cf0
 			  ((i > T_BLOCKSIZE) ? T_BLOCKSIZE : i)) == -1)
436cf0
 		{
436cf0
+			close(fdout);
436cf0
 			free (pn);
436cf0
 			return -1;
436cf0
 		}
436cf0
diff --git a/libtar/libtar.c b/libtar/libtar.c
436cf0
index 83564c8..673c90e 100644
436cf0
--- a/libtar/libtar.c
436cf0
+++ b/libtar/libtar.c
436cf0
@@ -83,7 +83,10 @@ gzopen_frontend(char *pathname, int oflags, int mode)
436cf0
 		return -1;
436cf0
 
436cf0
 	if ((oflags & O_CREAT) && fchmod(fd, mode))
436cf0
+	{
436cf0
+		close(fd);
436cf0
 		return -1;
436cf0
+	}
436cf0
 
436cf0
 	gzf = gzdopen(fd, gzoflags);
436cf0
 	if (!gzf)
436cf0
-- 
436cf0
1.7.1
436cf0