summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2013-02-20 16:01:48 +0100
committerDenys Vlasenko2013-02-20 16:01:48 +0100
commit8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099 (patch)
tree791e5b4612284420e94f8a73b490f28b576c1c13
parentd4d4f3528e0f7cb489ac05e57cc0d13b4c52e436 (diff)
downloadbusybox-8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099.zip
busybox-8e6a1ea8250137d1dd9b0a37b7a1d6d596a91099.tar.gz
rpm: unmap rpm file before working with next one
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/rpm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/archival/rpm.c b/archival/rpm.c
index b506f17..86ba4dc 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -305,16 +305,17 @@ int rpm_main(int argc, char **argv)
while (*argv) {
int rpm_fd;
- unsigned offset;
+ unsigned mapsize;
const char *source_rpm;
rpm_fd = xopen(*argv++, O_RDONLY);
G.mytags = rpm_gettags(rpm_fd, &G.tagcount);
if (!G.mytags)
bb_error_msg_and_die("error reading rpm header");
- offset = xlseek(rpm_fd, 0, SEEK_CUR);
+ mapsize = xlseek(rpm_fd, 0, SEEK_CUR);
+ mapsize = (mapsize + pagesize) & -(int)pagesize;
/* Some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */
- G.map = mmap(0, (offset + pagesize) & (-(int)pagesize), PROT_READ, MAP_PRIVATE, rpm_fd, 0);
+ G.map = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
//FIXME: error check?
source_rpm = rpm_getstr(TAG_SOURCERPM, 0);
@@ -386,6 +387,7 @@ int rpm_main(int argc, char **argv)
}
}
}
+ munmap(G.map, mapsize);
free(G.mytags);
close(rpm_fd);
}