Move setvbuf calls from gz_open() to calling functions, setvbuf is only supposed to be called prior to opening the stream, glibc tolerates later use, uclibc doesnt.
diff --git a/archival/gunzip.c b/archival/gunzip.c
index c4e8426..430bc63 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -118,6 +118,9 @@
/* Open input file */
in_file = xfopen(if_name, "r");
+ /* set the buffer size */
+ setvbuf(in_file, NULL, _IOFBF, 0x8000);
+
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
diff --git a/archival/tar.c b/archival/tar.c
index 31443ee..cf65798 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -284,6 +284,10 @@
/* unzip tarFd in a seperate process */
if (unzipFlag == TRUE) {
comp_file = fdopen(tarFd, "r");
+
+ /* set the buffer size */
+ setvbuf(comp_file, NULL, _IOFBF, 0x8000);
+
if ((tarFd = fileno(gz_open(comp_file, &pid))) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}
diff --git a/gunzip.c b/gunzip.c
index c4e8426..430bc63 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -118,6 +118,9 @@
/* Open input file */
in_file = xfopen(if_name, "r");
+ /* set the buffer size */
+ setvbuf(in_file, NULL, _IOFBF, 0x8000);
+
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index 5c5bb49..80dddb2 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -568,6 +568,9 @@
/* open the debian package to be worked on */
deb_stream = wfopen(package_filename, "r");
+ /* set the buffer size */
+ setvbuf(deb_stream, NULL, _IOFBF, 0x8000);
+
/* check ar magic */
fread(ar_magic, 1, 8, deb_stream);
if (strncmp(ar_magic,"!<arch>",7) != 0) {
diff --git a/tar.c b/tar.c
index 31443ee..cf65798 100644
--- a/tar.c
+++ b/tar.c
@@ -284,6 +284,10 @@
/* unzip tarFd in a seperate process */
if (unzipFlag == TRUE) {
comp_file = fdopen(tarFd, "r");
+
+ /* set the buffer size */
+ setvbuf(comp_file, NULL, _IOFBF, 0x8000);
+
if ((tarFd = fileno(gz_open(comp_file, &pid))) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}