aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/get_header_ar.c23
-rw-r--r--archival/libunarchive/get_header_tar.c4
2 files changed, 19 insertions, 8 deletions
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index 6638c65aa..4e294b2c0 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -9,6 +9,7 @@
9 9
10char get_header_ar(archive_handle_t *archive_handle) 10char get_header_ar(archive_handle_t *archive_handle)
11{ 11{
12 int err;
12 file_header_t *typed = archive_handle->file_header; 13 file_header_t *typed = archive_handle->file_header;
13 union { 14 union {
14 char raw[60]; 15 char raw[60];
@@ -45,15 +46,23 @@ char get_header_ar(archive_handle_t *archive_handle)
45 archive_handle->offset += 60; 46 archive_handle->offset += 60;
46 47
47 /* align the headers based on the header magic */ 48 /* align the headers based on the header magic */
48 if ((ar.formatted.magic[0] != '`') || (ar.formatted.magic[1] != '\n')) { 49 if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
49 bb_error_msg_and_die("invalid ar header"); 50 bb_error_msg_and_die("invalid ar header");
50 }
51 51
52 typed->mode = xstrtoul(ar.formatted.mode, 8); 52 /* FIXME: more thorough routine would be in order here */
53 typed->mtime = xatou(ar.formatted.date); 53 /* (we have something like that in tar) */
54 typed->uid = xatou(ar.formatted.uid); 54 /* but for now we are lax. This code works because */
55 typed->gid = xatou(ar.formatted.gid); 55 /* on misformatted numbers bb_strtou returns all-ones */
56 typed->size = xatoul(ar.formatted.size); 56 typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8);
57 if (err == -1) bb_error_msg_and_die("invalid ar header");
58 typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10);
59 if (err == -1) bb_error_msg_and_die("invalid ar header");
60 typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10);
61 if (err == -1) bb_error_msg_and_die("invalid ar header");
62 typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10);
63 if (err == -1) bb_error_msg_and_die("invalid ar header");
64 typed->size = err = bb_strtou(ar.formatted.size, NULL, 10);
65 if (err == -1) bb_error_msg_and_die("invalid ar header");
57 66
58 /* long filenames have '/' as the first character */ 67 /* long filenames have '/' as the first character */
59 if (ar.formatted.name[0] == '/') { 68 if (ar.formatted.name[0] == '/') {
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index beb8687c7..622f09fa5 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -74,8 +74,10 @@ char get_header_tar(archive_handle_t *archive_handle)
74 74
75 if (sizeof(tar) != 512) 75 if (sizeof(tar) != 512)
76 BUG_tar_header_size(); 76 BUG_tar_header_size();
77 again:
78 77
78#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
79 again:
80#endif
79 /* Align header */ 81 /* Align header */
80 data_align(archive_handle, 512); 82 data_align(archive_handle, 512);
81 83