libtar: fix handling of files bigger than 2 GiB

Change-Id: I96dc1b52b2e4edf366e70a927b263a9aab3e85b7
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
This commit is contained in:
Vojtech Bocek
2015-03-20 15:34:45 +01:00
parent 7e1b986a31
commit 78ab0c5807
3 changed files with 9 additions and 8 deletions
+2 -2
View File
@@ -233,8 +233,8 @@ tar_append_regfile(TAR *t, char *realname)
{
char block[T_BLOCKSIZE];
int filefd;
int i, j;
size_t size;
int j;
size_t size, i;
filefd = open(realname, O_RDONLY);
if (filefd == -1)
+6 -6
View File
@@ -192,11 +192,11 @@ int
tar_extract_regfile(TAR *t, char *realname, const int *progress_fd)
{
//mode_t mode;
size_t size;
size_t size, i;
//uid_t uid;
//gid_t gid;
int fdout;
int i, k;
int k;
char buf[T_BLOCKSIZE];
char *filename;
@@ -261,7 +261,7 @@ tar_extract_regfile(TAR *t, char *realname, const int *progress_fd)
#endif
/* extract the file */
for (i = size; i > 0; i -= T_BLOCKSIZE)
for (i = size; i > 0; i -= tar_min(i, T_BLOCKSIZE))
{
k = tar_block_read(t, buf);
if (k != T_BLOCKSIZE)
@@ -298,8 +298,8 @@ tar_extract_regfile(TAR *t, char *realname, const int *progress_fd)
int
tar_skip_regfile(TAR *t)
{
int i, k;
size_t size;
int k;
size_t size, i;
char buf[T_BLOCKSIZE];
if (!TH_ISREG(t))
@@ -309,7 +309,7 @@ tar_skip_regfile(TAR *t)
}
size = th_get_size(t);
for (i = size; i > 0; i -= T_BLOCKSIZE)
for (i = size; i > 0; i -= tar_min(i, T_BLOCKSIZE))
{
k = tar_block_read(t, buf);
if (k != T_BLOCKSIZE)
+1
View File
@@ -289,6 +289,7 @@ int oct_to_int(char *oct);
/* integer to string-octal conversion, no NULL */
void int_to_oct_nonull(int num, char *oct, size_t octlen);
#define tar_min(x, y) (x < y ? x : y)
/***** wrapper.c **********************************************************/