From 87e8d46f2934d2d5591b44b29f308adb93f4b128 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Tue, 3 Jul 2012 14:43:45 -0400 Subject: [PATCH] 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 --- checkpolicy/checkmodule.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c index 47603e02..cb58cf0d 100644 --- a/checkpolicy/checkmodule.c +++ b/checkpolicy/checkmodule.c @@ -63,10 +63,12 @@ static int read_binary_policy(policydb_t * p, char *file, char *progname) if (fstat(fd, &sb) < 0) { fprintf(stderr, "Can't stat '%s': %s\n", file, strerror(errno)); + close(fd); return -1; } map = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + close(fd); if (map == MAP_FAILED) { fprintf(stderr, "Can't map '%s': %s\n", file, strerror(errno)); return -1;