aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/tar.c
diff options
context:
space:
mode:
authorAshwini Sharma <ak.ashwini1981@gmail.com>2014-08-12 07:09:01 -0500
committerAshwini Sharma <ak.ashwini1981@gmail.com>2014-08-12 07:09:01 -0500
commit7eb3e4364c2bcebd2fdfef52c07f5101aa03e5bb (patch)
tree3a71927fe5198488d24af53b030d71797b67de35 /toys/pending/tar.c
parent6a77734d1b1ac1938abbc33014b60cfb49828824 (diff)
downloadtoybox-7eb3e4364c2bcebd2fdfef52c07f5101aa03e5bb.tar.gz
Patches to commands for issues reported from static analysis tool.
portability.h.patch - it is for O_CLOEXEC, as compiler complained of it. Makefile.patch - for cleaning generated/*.o files and libopts.dat file [Fixup to uniq.c from Rob.]
Diffstat (limited to 'toys/pending/tar.c')
-rw-r--r--toys/pending/tar.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/toys/pending/tar.c b/toys/pending/tar.c
index 12ee7af5..5b060c6e 100644
--- a/toys/pending/tar.c
+++ b/toys/pending/tar.c
@@ -84,8 +84,8 @@ static void copy_in_out(int src, int dst, off_t size)
cnt = size/512 + (rem?1:0);
for (i = 0; i < cnt; i++) {
- rd = (((i == cnt-1) && rem)? rem:512);
- if (readall(src, toybuf, rd) != rd) error_exit("short read");
+ rd = (i == cnt-1 && rem) ? rem : 512;
+ xreadall(src, toybuf, rd);
writeall(dst, toybuf, rd);
}
}
@@ -93,11 +93,10 @@ static void copy_in_out(int src, int dst, off_t size)
//convert to octal
static void itoo(char *str, int len, off_t val)
{
- char *t, tmp[sizeof(off_t)*3+1]; //1 for NUL termination
+ char *t, tmp[sizeof(off_t)*3+1];
int cnt = sprintf(tmp, "%0*llo", len, val);
- t = tmp;
- t += (cnt - len);
+ t = tmp + cnt - len;
if (*t == '0') t++;
memcpy(str, t, len);
}
@@ -547,7 +546,9 @@ static char *process_extended_hdr(struct archive_handler *tar, int size)
break;
}
}
- return ((value)?xstrdup(value) : NULL);
+ if (value) value = xstrdup(value);
+ free(buf);
+ return value;
}
static void tar_skip(struct archive_handler *tar, int sz)