Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/
Date: Wed, 07 Mar 2012 05:28:35
Message-Id: 1331098081.1860d33fc9c9d05907db9bf02f1c81e0f517c09f.vapier@gentoo
1 commit: 1860d33fc9c9d05907db9bf02f1c81e0f517c09f
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 7 05:25:41 2012 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 7 05:28:01 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=1860d33f
7
8 libsandbox: add missing close to logfile fd
9
10 When we log a lot, we end up leaking fd's, so make sure to clean them.
11
12 Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
13
14 ---
15 libsandbox/libsandbox.c | 7 +++++--
16 1 files changed, 5 insertions(+), 2 deletions(-)
17
18 diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
19 index 77a2415..e0b291a 100644
20 --- a/libsandbox/libsandbox.c
21 +++ b/libsandbox/libsandbox.c
22 @@ -468,6 +468,7 @@ static bool write_logfile(const char *logfile, const char *func, const char *pat
23 struct stat log_stat;
24 int stat_ret;
25 int logfd;
26 + bool ret = false;
27
28 stat_ret = lstat(logfile, &log_stat);
29 /* Do not care about failure */
30 @@ -523,10 +524,12 @@ static bool write_logfile(const char *logfile, const char *func, const char *pat
31 }
32 _SB_WRITE_STR("\n");
33
34 - return true;
35 + ret = true;
36
37 error:
38 - return false;
39 + sb_close(logfd);
40 +
41 + return ret;
42 }
43
44 static void init_context(sbcontext_t *context)