summaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/Kbuild2
-rw-r--r--archival/libunarchive/get_header_ar.c12
-rw-r--r--archival/libunarchive/get_header_tar.c45
-rw-r--r--archival/libunarchive/get_header_tar_bz2.c6
-rw-r--r--archival/libunarchive/get_header_tar_gz.c6
-rw-r--r--archival/libunarchive/get_header_tar_lzma.c5
-rw-r--r--archival/libunarchive/seek_by_jump.c2
-rw-r--r--archival/libunarchive/seek_by_read.c (renamed from archival/libunarchive/seek_by_char.c)8
8 files changed, 40 insertions, 46 deletions
diff --git a/archival/libunarchive/Kbuild b/archival/libunarchive/Kbuild
index c5f1bfb..4e14541 100644
--- a/archival/libunarchive/Kbuild
+++ b/archival/libunarchive/Kbuild
@@ -21,7 +21,7 @@ lib-y:= \
\
archive_xread_all_eof.o \
\
- seek_by_char.o \
+ seek_by_read.o \
seek_by_jump.o \
\
data_align.o \
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index cabb410..7372ada 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -46,14 +46,14 @@ char get_header_ar(archive_handle_t *archive_handle)
/* align the headers based on the header magic */
if ((ar.formatted.magic[0] != '`') || (ar.formatted.magic[1] != '\n')) {
- bb_error_msg_and_die("Invalid ar header");
+ bb_error_msg_and_die("invalid ar header");
}
- typed->mode = strtol(ar.formatted.mode, NULL, 8);
- typed->mtime = atoi(ar.formatted.date);
- typed->uid = atoi(ar.formatted.uid);
- typed->gid = atoi(ar.formatted.gid);
- typed->size = atoi(ar.formatted.size);
+ typed->mode = xstrtoul(ar.formatted.mode, 8);
+ typed->mtime = xatou(ar.formatted.date);
+ typed->uid = xatou(ar.formatted.uid);
+ typed->gid = xatou(ar.formatted.gid);
+ typed->size = xatoul(ar.formatted.size);
/* long filenames have '/' as the first character */
if (ar.formatted.name[0] == '/') {
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 0c622f4..d3cd96d 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -62,10 +62,10 @@ char get_header_tar(archive_handle_t *archive_handle)
* Read until the end to empty the pipe from gz or bz2
*/
while (full_read(archive_handle->src_fd, tar.raw, 512) == 512);
- return(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
end = 1;
- return(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
end = 0;
@@ -76,19 +76,18 @@ char get_header_tar(archive_handle_t *archive_handle)
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (strncmp(tar.formatted.magic, "\0\0\0\0\0", 5) != 0)
#endif
- bb_error_msg_and_die("Invalid tar magic");
+ bb_error_msg_and_die("invalid tar magic");
}
/* Do checksum on headers */
for (i = 0; i < 148 ; i++) {
sum += tar.raw[i];
}
sum += ' ' * 8;
- for (i = 156; i < 512 ; i++) {
+ for (i = 156; i < 512 ; i++) {
sum += tar.raw[i];
}
- if (sum != strtol(tar.formatted.chksum, NULL, 8)) {
- bb_error_msg("Invalid tar header checksum");
- return(EXIT_FAILURE);
+ if (sum != xstrtoul(tar.formatted.chksum, 8)) {
+ bb_error_msg_and_die("invalid tar header checksum");
}
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
@@ -102,8 +101,7 @@ char get_header_tar(archive_handle_t *archive_handle)
} else
#endif
{
- file_header->name = xstrndup(tar.formatted.name,100);
-
+ file_header->name = xstrndup(tar.formatted.name, 100);
if (tar.formatted.prefix[0]) {
char *temp = file_header->name;
file_header->name = concat_path_file(tar.formatted.prefix, temp);
@@ -111,17 +109,18 @@ char get_header_tar(archive_handle_t *archive_handle)
}
}
- file_header->uid = strtol(tar.formatted.uid, NULL, 8);
- file_header->gid = strtol(tar.formatted.gid, NULL, 8);
- file_header->size = strtol(tar.formatted.size, NULL, 8);
- file_header->mtime = strtol(tar.formatted.mtime, NULL, 8);
- file_header->link_name = (tar.formatted.linkname[0] != '\0') ?
- xstrdup(tar.formatted.linkname) : NULL;
- file_header->device = makedev(strtol(tar.formatted.devmajor, NULL, 8),
- strtol(tar.formatted.devminor, NULL, 8));
+ file_header->uid = xstrtoul(tar.formatted.uid, 8);
+ file_header->gid = xstrtoul(tar.formatted.gid, 8);
+ // TODO: LFS support
+ file_header->size = xstrtoul(tar.formatted.size, 8);
+ file_header->mtime = xstrtoul(tar.formatted.mtime, 8);
+ file_header->link_name = tar.formatted.linkname[0] ?
+ xstrdup(tar.formatted.linkname) : NULL;
+ file_header->device = makedev(xstrtoul(tar.formatted.devmajor, 8),
+ xstrtoul(tar.formatted.devminor, 8));
/* Set bits 0-11 of the files mode */
- file_header->mode = 07777 & strtol(tar.formatted.mode, NULL, 8);
+ file_header->mode = 07777 & xstrtoul(tar.formatted.mode, 8);
/* Set bits 12-15 of the files mode */
switch (tar.formatted.typeflag) {
@@ -161,7 +160,7 @@ char get_header_tar(archive_handle_t *archive_handle)
xread(archive_handle->src_fd, longname, file_header->size);
archive_handle->offset += file_header->size;
- return(get_header_tar(archive_handle));
+ return get_header_tar(archive_handle);
}
case 'K': {
linkname = xzalloc(file_header->size + 1);
@@ -169,7 +168,7 @@ char get_header_tar(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
file_header->name = linkname;
- return(get_header_tar(archive_handle));
+ return get_header_tar(archive_handle);
}
case 'D': /* GNU dump dir */
case 'M': /* Continuation of multi volume archive*/
@@ -179,10 +178,10 @@ char get_header_tar(archive_handle_t *archive_handle)
#endif
case 'g': /* pax global header */
case 'x': /* pax extended header */
- bb_error_msg("Ignoring extension type %c", tar.formatted.typeflag);
+ bb_error_msg("ignoring extension type %c", tar.formatted.typeflag);
break;
default:
- bb_error_msg("Unknown typeflag: 0x%x", tar.formatted.typeflag);
+ bb_error_msg("unknown typeflag: 0x%x", tar.formatted.typeflag);
}
{ /* Strip trailing '/' in directories */
/* Must be done after mode is set as '/' is used to check if its a directory */
@@ -204,5 +203,5 @@ char get_header_tar(archive_handle_t *archive_handle)
free(file_header->link_name);
- return(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/archival/libunarchive/get_header_tar_bz2.c b/archival/libunarchive/get_header_tar_bz2.c
index a8b6308..e3cb328 100644
--- a/archival/libunarchive/get_header_tar_bz2.c
+++ b/archival/libunarchive/get_header_tar_bz2.c
@@ -16,12 +16,12 @@
char get_header_tar_bz2(archive_handle_t *archive_handle)
{
/* Cant lseek over pipe's */
- archive_handle->seek = seek_by_char;
+ archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
archive_handle->offset = 0;
- while (get_header_tar(archive_handle) == EXIT_SUCCESS);
+ while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
- return(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c
index 24e4f9c..af059a1 100644
--- a/archival/libunarchive/get_header_tar_gz.c
+++ b/archival/libunarchive/get_header_tar_gz.c
@@ -13,7 +13,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
unsigned char magic[2];
/* Cant lseek over pipe's */
- archive_handle->seek = seek_by_char;
+ archive_handle->seek = seek_by_read;
xread(archive_handle->src_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
@@ -24,8 +24,8 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
archive_handle->offset = 0;
- while (get_header_tar(archive_handle) == EXIT_SUCCESS);
+ while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
- return(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
diff --git a/archival/libunarchive/get_header_tar_lzma.c b/archival/libunarchive/get_header_tar_lzma.c
index e38583f..06b8daa 100644
--- a/archival/libunarchive/get_header_tar_lzma.c
+++ b/archival/libunarchive/get_header_tar_lzma.c
@@ -11,13 +11,12 @@
char get_header_tar_lzma(archive_handle_t * archive_handle)
{
/* Can't lseek over pipes */
- archive_handle->seek = seek_by_char;
+ archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
archive_handle->offset = 0;
- while (get_header_tar(archive_handle) == EXIT_SUCCESS);
+ while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return EXIT_FAILURE;
}
-
diff --git a/archival/libunarchive/seek_by_jump.c b/archival/libunarchive/seek_by_jump.c
index 231360f..e1917dd 100644
--- a/archival/libunarchive/seek_by_jump.c
+++ b/archival/libunarchive/seek_by_jump.c
@@ -16,7 +16,7 @@ void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amo
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
- seek_by_char(archive_handle, amount);
+ seek_by_read(archive_handle, amount);
} else
#endif
bb_perror_msg_and_die("Seek failure");
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_read.c
index f4d8c2f..03cbb9e 100644
--- a/archival/libunarchive/seek_by_char.c
+++ b/archival/libunarchive/seek_by_read.c
@@ -8,14 +8,10 @@
#include "unarchive.h"
#include "libbb.h"
-
-
-/* If we are reading through a pipe(), or from stdin then we cant lseek,
+/* If we are reading through a pipe(), or from stdin then we cant lseek,
* we must read and discard the data to skip over it.
- *
- * TODO: rename to seek_by_read
*/
-void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
+void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
if (jump_size) {
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);