diff options
Diffstat (limited to 'archival/rpm.c')
-rw-r--r-- | archival/rpm.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/archival/rpm.c b/archival/rpm.c index 78568687e..4c36067c4 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -115,8 +115,8 @@ int rpm_main(int argc, char **argv) | |||
115 | } | 115 | } |
116 | } | 116 | } |
117 | argv += optind; | 117 | argv += optind; |
118 | argc -= optind; | 118 | //argc -= optind; |
119 | if (!argc) bb_show_usage(); | 119 | if (!argv[0]) bb_show_usage(); |
120 | 120 | ||
121 | while (*argv) { | 121 | while (*argv) { |
122 | rpm_fd = xopen(*argv++, O_RDONLY); | 122 | rpm_fd = xopen(*argv++, O_RDONLY); |
@@ -251,7 +251,7 @@ static void extract_cpio_gz(int fd) | |||
251 | static rpm_index **rpm_gettags(int fd, int *num_tags) | 251 | static rpm_index **rpm_gettags(int fd, int *num_tags) |
252 | { | 252 | { |
253 | /* We should never need mode than 200, and realloc later */ | 253 | /* We should never need mode than 200, and realloc later */ |
254 | rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *)); | 254 | rpm_index **tags = xzalloc(200 * sizeof(tags[0])); |
255 | int pass, tagindex = 0; | 255 | int pass, tagindex = 0; |
256 | 256 | ||
257 | xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */ | 257 | xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */ |
@@ -265,6 +265,9 @@ static rpm_index **rpm_gettags(int fd, int *num_tags) | |||
265 | uint32_t entries; /* Number of entries in header (4 bytes) */ | 265 | uint32_t entries; /* Number of entries in header (4 bytes) */ |
266 | uint32_t size; /* Size of store (4 bytes) */ | 266 | uint32_t size; /* Size of store (4 bytes) */ |
267 | } header; | 267 | } header; |
268 | struct BUG_header { | ||
269 | char BUG_header[sizeof(header) == 16 ? 1 : -1]; | ||
270 | }; | ||
268 | rpm_index *tmpindex; | 271 | rpm_index *tmpindex; |
269 | int storepos; | 272 | int storepos; |
270 | 273 | ||
@@ -278,8 +281,8 @@ static rpm_index **rpm_gettags(int fd, int *num_tags) | |||
278 | storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16; | 281 | storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16; |
279 | 282 | ||
280 | while (header.entries--) { | 283 | while (header.entries--) { |
281 | tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index)); | 284 | tmpindex = tags[tagindex++] = xmalloc(sizeof(*tmpindex)); |
282 | xread(fd, tmpindex, sizeof(rpm_index)); | 285 | xread(fd, tmpindex, sizeof(*tmpindex)); |
283 | tmpindex->tag = ntohl(tmpindex->tag); | 286 | tmpindex->tag = ntohl(tmpindex->tag); |
284 | tmpindex->type = ntohl(tmpindex->type); | 287 | tmpindex->type = ntohl(tmpindex->type); |
285 | tmpindex->count = ntohl(tmpindex->count); | 288 | tmpindex->count = ntohl(tmpindex->count); |
@@ -292,7 +295,7 @@ static rpm_index **rpm_gettags(int fd, int *num_tags) | |||
292 | if (pass == 0) | 295 | if (pass == 0) |
293 | xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); | 296 | xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); |
294 | } | 297 | } |
295 | tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */ | 298 | tags = xrealloc(tags, tagindex * sizeof(tags[0])); /* realloc tags to save space */ |
296 | *num_tags = tagindex; | 299 | *num_tags = tagindex; |
297 | return tags; /* All done, leave the file at the start of the gzipped cpio archive */ | 300 | return tags; /* All done, leave the file at the start of the gzipped cpio archive */ |
298 | } | 301 | } |