mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-08 22:49:44 +00:00
policycoreutils: checkmodule: fd leak reading policy
We never closed the fd to the policy file. Close this fd as soon as we are finished with it. Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
parent
1db01640ee
commit
87e8d46f29
@ -63,10 +63,12 @@ static int read_binary_policy(policydb_t * p, char *file, char *progname)
|
|||||||
if (fstat(fd, &sb) < 0) {
|
if (fstat(fd, &sb) < 0) {
|
||||||
fprintf(stderr, "Can't stat '%s': %s\n",
|
fprintf(stderr, "Can't stat '%s': %s\n",
|
||||||
file, strerror(errno));
|
file, strerror(errno));
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
map =
|
map =
|
||||||
mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||||
|
close(fd);
|
||||||
if (map == MAP_FAILED) {
|
if (map == MAP_FAILED) {
|
||||||
fprintf(stderr, "Can't map '%s': %s\n", file, strerror(errno));
|
fprintf(stderr, "Can't map '%s': %s\n", file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user