summaryrefslogtreecommitdiff
path: root/libbb/untar.c
diff options
context:
space:
mode:
authorGlenn L McGrath2001-04-12 13:49:09 +0000
committerGlenn L McGrath2001-04-12 13:49:09 +0000
commit3e2ab88ee2e488df1b674655f0038729a635aa52 (patch)
tree40aecd08a39f0f1ad7074f2a1003ace79bb4c641 /libbb/untar.c
parentc9cac5be236475e91af1865a2dae2c2af5f19fd6 (diff)
downloadbusybox-3e2ab88ee2e488df1b674655f0038729a635aa52.zip
busybox-3e2ab88ee2e488df1b674655f0038729a635aa52.tar.gz
New dpkg-deb function -t, stands for --fsys-tarfile
Diffstat (limited to 'libbb/untar.c')
-rw-r--r--libbb/untar.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/libbb/untar.c b/libbb/untar.c
index 9f7bd30..11c55df 100644
--- a/libbb/untar.c
+++ b/libbb/untar.c
@@ -55,13 +55,26 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
while (fread((char *) &raw_tar_header, 1, 512, src_tar_file) == 512) {
long sum = 0;
char *dir = NULL;
+
+ if (ferror(src_tar_file) || feof(src_tar_file)) {
+ break;
+ }
uncompressed_count += 512;
/* Check header has valid magic */
if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) {
- /* Put this pack after TODO (check child still alive) is done */
- error_msg("Invalid tar magic");
+/*
+ * FIXME, Need HELP with this
+ *
+ * This has to fail silently or it incorrectly reports errors when called from
+ * deb_extract.
+ * The problem is deb_extract decompresses the .gz file in a child process and
+ * untar reads from the child proccess. The child process finishes and exits,
+ * but fread reads 0's from the src_tar_file even though the child
+ * closed its handle.
+ */
+// error_msg("Invalid tar magic");
break;
}
@@ -109,7 +122,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
}
*/
- if (untar_function & (extract_verbose_extract | extract_contents)) {
+ if (untar_function & (extract_contents | extract_verbose_extract)) {
printf("%s\n", raw_tar_header.name);
}
@@ -144,7 +157,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
break;
}
case '5':
- if (untar_function & (extract_extract | extract_verbose_extract)) {
+ if (untar_function & extract_extract) {
if (create_path(dir, mode) != TRUE) {
free(dir);
perror_msg("%s: Cannot mkdir", raw_tar_header.name);