aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/check_header_gzip.c11
-rw-r--r--archival/libunarchive/data_extract_all.c1
-rw-r--r--archival/libunarchive/decompress_uncompress.c26
-rw-r--r--archival/libunarchive/filter_accept_all.c6
-rw-r--r--archival/libunarchive/get_header_tar.c1
-rw-r--r--archival/libunarchive/get_header_tar_gz.c9
-rw-r--r--archival/libunarchive/uncompress.c26
7 files changed, 35 insertions, 45 deletions
diff --git a/archival/libunarchive/check_header_gzip.c b/archival/libunarchive/check_header_gzip.c
index 508d30924..e8bb8d547 100644
--- a/archival/libunarchive/check_header_gzip.c
+++ b/archival/libunarchive/check_header_gzip.c
@@ -5,9 +5,8 @@
extern void check_header_gzip(int src_fd)
{
union {
- unsigned char raw[10];
+ unsigned char raw[8];
struct {
- unsigned char magic[2];
unsigned char method;
unsigned char flags;
unsigned int mtime;
@@ -16,13 +15,7 @@ extern void check_header_gzip(int src_fd)
} formated;
} header;
- xread_all(src_fd, header.raw, 10);
-
- /* Magic header for gzip files, 1F 8B = \037\213 */
- if ((header.formated.magic[0] != 0x1F)
- || (header.formated.magic[1] != 0x8b)) {
- error_msg_and_die("Invalid gzip magic");
- }
+ xread_all(src_fd, header.raw, 8);
/* Check the compression method */
if (header.formated.method != 8) {
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 20d99aa58..a80f422b7 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -18,7 +18,6 @@ extern void data_extract_all(archive_handle_t *archive_handle)
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *dir = dirname(strdup(file_header->name));
make_directory (dir, 0777, FILEUTILS_RECUR);
- free(dir);
}
/* Create the file */
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c
index 903e6aa6d..949e27df1 100644
--- a/archival/libunarchive/decompress_uncompress.c
+++ b/archival/libunarchive/decompress_uncompress.c
@@ -28,8 +28,9 @@
* [... History snipped ...]
*
*/
-#include <stdio.h>
-
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
#define IBUFSIZ 2048 /* Defailt input buffer size */
#define OBUFSIZ 2048 /* Default output buffer size */
@@ -95,9 +96,6 @@ unsigned short codetab[HSIZE];
#define clear_tab_prefixof() memset(codetab, 0, 256);
-extern int uncompress ( FILE *, FILE * );
-
-
/*
* Decompress stdin to stdout. This routine adapts to the codes in the
* file building the "string" table on-the-fly; requiring no table to
@@ -105,7 +103,7 @@ extern int uncompress ( FILE *, FILE * );
* with those of the compress() routine. See the definitions above.
*/
-int uncompress ( FILE * fdin, FILE * fdout )
+extern int uncompress(int fd_in, int fd_out)
{
char_type *stackp;
code_int code;
@@ -125,7 +123,7 @@ int uncompress ( FILE * fdin, FILE * fdout )
insize = 0;
- inbuf [0] = fgetc(fdin);
+ inbuf [0] = xread_char(fd_in);
maxbits = inbuf[0] & BIT_MASK;
block_mode = inbuf[0] & BLOCK_MODE;
@@ -173,11 +171,7 @@ resetbuf: ;
if (insize < (int) sizeof(inbuf)-IBUFSIZ)
{
- rsize = fread(inbuf+insize, 1,IBUFSIZ,fdin);
-
- if ( !rsize && ferror(fdin))
- return -1;
-
+ xread_all(fd_in, inbuf+insize, IBUFSIZ);
insize += rsize;
}
@@ -275,8 +269,7 @@ resetbuf: ;
if (outpos >= OBUFSIZ)
{
- fwrite(outbuf, 1,outpos,fdout);
-
+ write(fd_out, outbuf, outpos);
outpos = 0;
}
stackp+= i;
@@ -303,8 +296,9 @@ resetbuf: ;
}
while (rsize > 0);
- if (outpos > 0)
- fwrite(outbuf, outpos,1, fdout);
+ if (outpos > 0) {
+ write(fd_out, outbuf, outpos);
+ }
return 0;
}
diff --git a/archival/libunarchive/filter_accept_all.c b/archival/libunarchive/filter_accept_all.c
index 0471ccef0..2838ea1f2 100644
--- a/archival/libunarchive/filter_accept_all.c
+++ b/archival/libunarchive/filter_accept_all.c
@@ -6,5 +6,9 @@
*/
extern char filter_accept_all(const llist_t *accept_list, const llist_t *reject_list, const char *key)
{
- return(EXIT_SUCCESS);
+ if (key) {
+ return(EXIT_SUCCESS);
+ } else {
+ return(EXIT_FAILURE);
+ }
}
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 2c8fc0aa0..bb0affeb3 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -155,7 +155,6 @@ extern char get_header_tar(archive_handle_t *archive_handle)
# endif
}
#endif
-
if (archive_handle->filter(archive_handle->accept, archive_handle->reject, archive_handle->file_header->name) == EXIT_SUCCESS) {
archive_handle->action_header(archive_handle->file_header);
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c
index c06beac9d..24d19fbfd 100644
--- a/archival/libunarchive/get_header_tar_gz.c
+++ b/archival/libunarchive/get_header_tar_gz.c
@@ -27,11 +27,17 @@ extern char get_header_tar_gz(archive_handle_t *archive_handle)
{
int fd_pipe[2];
int pid;
+ unsigned char magic[2];
+
+ xread_all(archive_handle->src_fd, &magic, 2);
+ if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
+ error_msg_and_die("Invalid gzip magic");
+ }
check_header_gzip(archive_handle->src_fd);
if (pipe(fd_pipe) != 0) {
- error_msg_and_die("Can't create pipe\n");
+ error_msg_and_die("Can't create pipe");
}
pid = fork();
@@ -54,6 +60,7 @@ extern char get_header_tar_gz(archive_handle_t *archive_handle)
archive_handle->src_fd = fd_pipe[0];
+ archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
if (kill(pid, SIGTERM) == -1) {
diff --git a/archival/libunarchive/uncompress.c b/archival/libunarchive/uncompress.c
index 903e6aa6d..949e27df1 100644
--- a/archival/libunarchive/uncompress.c
+++ b/archival/libunarchive/uncompress.c
@@ -28,8 +28,9 @@
* [... History snipped ...]
*
*/
-#include <stdio.h>
-
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
#define IBUFSIZ 2048 /* Defailt input buffer size */
#define OBUFSIZ 2048 /* Default output buffer size */
@@ -95,9 +96,6 @@ unsigned short codetab[HSIZE];
#define clear_tab_prefixof() memset(codetab, 0, 256);
-extern int uncompress ( FILE *, FILE * );
-
-
/*
* Decompress stdin to stdout. This routine adapts to the codes in the
* file building the "string" table on-the-fly; requiring no table to
@@ -105,7 +103,7 @@ extern int uncompress ( FILE *, FILE * );
* with those of the compress() routine. See the definitions above.
*/
-int uncompress ( FILE * fdin, FILE * fdout )
+extern int uncompress(int fd_in, int fd_out)
{
char_type *stackp;
code_int code;
@@ -125,7 +123,7 @@ int uncompress ( FILE * fdin, FILE * fdout )
insize = 0;
- inbuf [0] = fgetc(fdin);
+ inbuf [0] = xread_char(fd_in);
maxbits = inbuf[0] & BIT_MASK;
block_mode = inbuf[0] & BLOCK_MODE;
@@ -173,11 +171,7 @@ resetbuf: ;
if (insize < (int) sizeof(inbuf)-IBUFSIZ)
{
- rsize = fread(inbuf+insize, 1,IBUFSIZ,fdin);
-
- if ( !rsize && ferror(fdin))
- return -1;
-
+ xread_all(fd_in, inbuf+insize, IBUFSIZ);
insize += rsize;
}
@@ -275,8 +269,7 @@ resetbuf: ;
if (outpos >= OBUFSIZ)
{
- fwrite(outbuf, 1,outpos,fdout);
-
+ write(fd_out, outbuf, outpos);
outpos = 0;
}
stackp+= i;
@@ -303,8 +296,9 @@ resetbuf: ;
}
while (rsize > 0);
- if (outpos > 0)
- fwrite(outbuf, outpos,1, fdout);
+ if (outpos > 0) {
+ write(fd_out, outbuf, outpos);
+ }
return 0;
}