diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-01 12:54:56 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-01 12:54:56 +0000 |
commit | 1a9e9bdd93b06508b70bd29ef5eeb82f91d86222 (patch) | |
tree | adcf234f48d8a68a5644f1504cc93025d58ce2a2 /archival/libunarchive | |
parent | 5a89763fb7e57d4fc3d393eafa35c58f8285a083 (diff) | |
download | busybox-w32-1a9e9bdd93b06508b70bd29ef5eeb82f91d86222.tar.gz busybox-w32-1a9e9bdd93b06508b70bd29ef5eeb82f91d86222.tar.bz2 busybox-w32-1a9e9bdd93b06508b70bd29ef5eeb82f91d86222.zip |
gunzip: restore mtime. approx +80 bytes of code
rpm: make code more robust
lsmod: small code shrink
Diffstat (limited to 'archival/libunarchive')
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index f25808a1a..e83cd4f45 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c | |||
@@ -1108,18 +1108,21 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY) | |||
1108 | return res; | 1108 | return res; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | static int check_header_gzip(STATE_PARAM_ONLY) | 1111 | static int check_header_gzip(STATE_PARAM unpack_info_t *info) |
1112 | { | 1112 | { |
1113 | union { | 1113 | union { |
1114 | unsigned char raw[8]; | 1114 | unsigned char raw[8]; |
1115 | struct { | 1115 | struct { |
1116 | uint8_t gz_method; | 1116 | uint8_t gz_method; |
1117 | uint8_t flags; | 1117 | uint8_t flags; |
1118 | //uint32_t mtime; - unused fields | 1118 | uint32_t mtime; |
1119 | //uint8_t xtra_flags; | 1119 | uint8_t xtra_flags_UNUSED; |
1120 | //uint8_t os_flags; | 1120 | uint8_t os_flags_UNUSED; |
1121 | } formatted; /* packed */ | 1121 | } __attribute__((packed)) formatted; |
1122 | } header; | 1122 | } header; |
1123 | struct BUG_header { | ||
1124 | char BUG_header[sizeof(header) == 8 ? 1 : -1]; | ||
1125 | }; | ||
1123 | 1126 | ||
1124 | /* | 1127 | /* |
1125 | * Rewind bytebuffer. We use the beginning because the header has 8 | 1128 | * Rewind bytebuffer. We use the beginning because the header has 8 |
@@ -1167,6 +1170,9 @@ static int check_header_gzip(STATE_PARAM_ONLY) | |||
1167 | } | 1170 | } |
1168 | } | 1171 | } |
1169 | 1172 | ||
1173 | if (info) | ||
1174 | info->mtime = SWAP_LE32(header.formatted.mtime); | ||
1175 | |||
1170 | /* Read the header checksum */ | 1176 | /* Read the header checksum */ |
1171 | if (header.formatted.flags & 0x02) { | 1177 | if (header.formatted.flags & 0x02) { |
1172 | if (!top_up(PASS_STATE 2)) | 1178 | if (!top_up(PASS_STATE 2)) |
@@ -1177,7 +1183,7 @@ static int check_header_gzip(STATE_PARAM_ONLY) | |||
1177 | } | 1183 | } |
1178 | 1184 | ||
1179 | USE_DESKTOP(long long) int FAST_FUNC | 1185 | USE_DESKTOP(long long) int FAST_FUNC |
1180 | unpack_gz_stream(int in, int out) | 1186 | unpack_gz_stream_with_info(int in, int out, unpack_info_t *info) |
1181 | { | 1187 | { |
1182 | uint32_t v32; | 1188 | uint32_t v32; |
1183 | USE_DESKTOP(long long) int n; | 1189 | USE_DESKTOP(long long) int n; |
@@ -1192,7 +1198,7 @@ unpack_gz_stream(int in, int out) | |||
1192 | gunzip_src_fd = in; | 1198 | gunzip_src_fd = in; |
1193 | 1199 | ||
1194 | again: | 1200 | again: |
1195 | if (!check_header_gzip(PASS_STATE_ONLY)) { | 1201 | if (!check_header_gzip(PASS_STATE info)) { |
1196 | bb_error_msg("corrupted data"); | 1202 | bb_error_msg("corrupted data"); |
1197 | n = -1; | 1203 | n = -1; |
1198 | goto ret; | 1204 | goto ret; |
@@ -1239,3 +1245,9 @@ unpack_gz_stream(int in, int out) | |||
1239 | DEALLOC_STATE; | 1245 | DEALLOC_STATE; |
1240 | return n; | 1246 | return n; |
1241 | } | 1247 | } |
1248 | |||
1249 | USE_DESKTOP(long long) int FAST_FUNC | ||
1250 | unpack_gz_stream(int in, int out) | ||
1251 | { | ||
1252 | return unpack_gz_stream_with_info(in, out, NULL); | ||
1253 | } | ||