7 |
#include "libbb.h" |
#include "libbb.h" |
8 |
#include "unarchive.h" |
#include "unarchive.h" |
9 |
|
|
10 |
char get_header_ar(archive_handle_t *archive_handle) |
char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) |
11 |
{ |
{ |
12 |
int err; |
int err; |
13 |
file_header_t *typed = archive_handle->file_header; |
file_header_t *typed = archive_handle->file_header; |
23 |
char magic[2]; |
char magic[2]; |
24 |
} formatted; |
} formatted; |
25 |
} ar; |
} ar; |
26 |
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES |
#if ENABLE_FEATURE_AR_LONG_FILENAMES |
27 |
static char *ar_long_names; |
static char *ar_long_names; |
28 |
static unsigned int ar_long_name_size; |
static unsigned ar_long_name_size; |
29 |
#endif |
#endif |
30 |
|
|
31 |
/* dont use xread as we want to handle the error ourself */ |
/* dont use xread as we want to handle the error ourself */ |
66 |
|
|
67 |
/* long filenames have '/' as the first character */ |
/* long filenames have '/' as the first character */ |
68 |
if (ar.formatted.name[0] == '/') { |
if (ar.formatted.name[0] == '/') { |
69 |
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES |
#if ENABLE_FEATURE_AR_LONG_FILENAMES |
70 |
|
unsigned long_offset; |
71 |
|
|
72 |
if (ar.formatted.name[1] == '/') { |
if (ar.formatted.name[1] == '/') { |
73 |
/* If the second char is a '/' then this entries data section |
/* If the second char is a '/' then this entries data section |
74 |
* stores long filename for multiple entries, they are stored |
* stores long filename for multiple entries, they are stored |
80 |
/* This ar entries data section only contained filenames for other records |
/* This ar entries data section only contained filenames for other records |
81 |
* they are stored in the static ar_long_names for future reference */ |
* they are stored in the static ar_long_names for future reference */ |
82 |
return get_header_ar(archive_handle); /* Return next header */ |
return get_header_ar(archive_handle); /* Return next header */ |
83 |
} else if (ar.formatted.name[1] == ' ') { |
} |
84 |
|
|
85 |
|
if (ar.formatted.name[1] == ' ') { |
86 |
/* This is the index of symbols in the file for compilers */ |
/* This is the index of symbols in the file for compilers */ |
87 |
data_skip(archive_handle); |
data_skip(archive_handle); |
88 |
archive_handle->offset += typed->size; |
archive_handle->offset += typed->size; |
89 |
return get_header_ar(archive_handle); /* Return next header */ |
return get_header_ar(archive_handle); /* Return next header */ |
|
} else { |
|
|
/* The number after the '/' indicates the offset in the ar data section |
|
|
(saved in variable long_name) that conatains the real filename */ |
|
|
const unsigned int long_offset = atoi(&ar.formatted.name[1]); |
|
|
if (long_offset >= ar_long_name_size) { |
|
|
bb_error_msg_and_die("can't resolve long filename"); |
|
|
} |
|
|
typed->name = xstrdup(ar_long_names + long_offset); |
|
90 |
} |
} |
91 |
|
|
92 |
|
/* The number after the '/' indicates the offset in the ar data section |
93 |
|
* (saved in variable long_name) that conatains the real filename */ |
94 |
|
long_offset = atoi(&ar.formatted.name[1]); |
95 |
|
if (long_offset >= ar_long_name_size) { |
96 |
|
bb_error_msg_and_die("can't resolve long filename"); |
97 |
|
} |
98 |
|
typed->name = xstrdup(ar_long_names + long_offset); |
99 |
#else |
#else |
100 |
bb_error_msg_and_die("long filenames not supported"); |
bb_error_msg_and_die("long filenames not supported"); |
101 |
#endif |
#endif |
108 |
|
|
109 |
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { |
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { |
110 |
archive_handle->action_header(typed); |
archive_handle->action_header(typed); |
111 |
|
#if ENABLE_DPKG || ENABLE_DPKG_DEB |
112 |
if (archive_handle->sub_archive) { |
if (archive_handle->sub_archive) { |
113 |
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS) |
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS) |
114 |
/* repeat */; |
continue; |
115 |
} else { |
} else |
116 |
|
#endif |
117 |
archive_handle->action_data(archive_handle); |
archive_handle->action_data(archive_handle); |
|
} |
|
118 |
} else { |
} else { |
119 |
data_skip(archive_handle); |
data_skip(archive_handle); |
120 |
} |
} |