summaryrefslogtreecommitdiffstats
path: root/libtar
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2015-03-20 15:34:45 +0100
committerVojtech Bocek <vbocek@gmail.com>2015-03-20 15:34:45 +0100
commit78ab0c5807c17e343cc4fa9af86ea2d787e0e047 (patch)
tree946fa3012624fa64ff64b3ca67019a7163fccdda /libtar
parentupdater: only include tune2fs support when libtune2fs is available (diff)
downloadandroid_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar.gz
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar.bz2
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar.lz
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar.xz
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.tar.zst
android_bootable_recovery-78ab0c5807c17e343cc4fa9af86ea2d787e0e047.zip
Diffstat (limited to 'libtar')
-rw-r--r--libtar/append.c4
-rw-r--r--libtar/extract.c12
-rw-r--r--libtar/libtar.h1
3 files changed, 9 insertions, 8 deletions
diff --git a/libtar/append.c b/libtar/append.c
index 514cf54bb..1831990be 100644
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -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)
diff --git a/libtar/extract.c b/libtar/extract.c
index e605aca43..4532b7640 100644
--- a/libtar/extract.c
+++ b/libtar/extract.c
@@ -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)
diff --git a/libtar/libtar.h b/libtar/libtar.h
index e3154ae90..d2c4d003c 100644
--- a/libtar/libtar.h
+++ b/libtar/libtar.h
@@ -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 **********************************************************/