diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-02-20 16:01:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-02-20 16:01:48 +0100 |
commit | 8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099 (patch) | |
tree | 791e5b4612284420e94f8a73b490f28b576c1c13 | |
parent | d4d4f3528e0f7cb489ac05e57cc0d13b4c52e436 (diff) | |
download | busybox-w32-8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099.tar.gz busybox-w32-8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099.tar.bz2 busybox-w32-8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099.zip |
rpm: unmap rpm file before working with next one
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/rpm.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/archival/rpm.c b/archival/rpm.c index b506f1779..86ba4dca4 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -305,16 +305,17 @@ int rpm_main(int argc, char **argv) | |||
305 | 305 | ||
306 | while (*argv) { | 306 | while (*argv) { |
307 | int rpm_fd; | 307 | int rpm_fd; |
308 | unsigned offset; | 308 | unsigned mapsize; |
309 | const char *source_rpm; | 309 | const char *source_rpm; |
310 | 310 | ||
311 | rpm_fd = xopen(*argv++, O_RDONLY); | 311 | rpm_fd = xopen(*argv++, O_RDONLY); |
312 | G.mytags = rpm_gettags(rpm_fd, &G.tagcount); | 312 | G.mytags = rpm_gettags(rpm_fd, &G.tagcount); |
313 | if (!G.mytags) | 313 | if (!G.mytags) |
314 | bb_error_msg_and_die("error reading rpm header"); | 314 | bb_error_msg_and_die("error reading rpm header"); |
315 | offset = xlseek(rpm_fd, 0, SEEK_CUR); | 315 | mapsize = xlseek(rpm_fd, 0, SEEK_CUR); |
316 | mapsize = (mapsize + pagesize) & -(int)pagesize; | ||
316 | /* Some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */ | 317 | /* Some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */ |
317 | G.map = mmap(0, (offset + pagesize) & (-(int)pagesize), PROT_READ, MAP_PRIVATE, rpm_fd, 0); | 318 | G.map = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, rpm_fd, 0); |
318 | //FIXME: error check? | 319 | //FIXME: error check? |
319 | 320 | ||
320 | source_rpm = rpm_getstr(TAG_SOURCERPM, 0); | 321 | source_rpm = rpm_getstr(TAG_SOURCERPM, 0); |
@@ -386,6 +387,7 @@ int rpm_main(int argc, char **argv) | |||
386 | } | 387 | } |
387 | } | 388 | } |
388 | } | 389 | } |
390 | munmap(G.map, mapsize); | ||
389 | free(G.mytags); | 391 | free(G.mytags); |
390 | close(rpm_fd); | 392 | close(rpm_fd); |
391 | } | 393 | } |