summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-28 11:33:43 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-03-28 11:33:43 -0700
commit9b9ec3cfd1db9fac09b119715dabc36aaa77f497 (patch)
tree683007524f8df2e0e6a6b04a5051937d320479cf
parent3d7e713e85af18d7e52cafdc9d20a2715048dee7 (diff)
Set close-on-exec when opening files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--cursor/load_cursor.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/cursor/load_cursor.c b/cursor/load_cursor.c
index e82fc63..7cd53cf 100644
--- a/cursor/load_cursor.c
+++ b/cursor/load_cursor.c
@@ -44,6 +44,13 @@
#include "cursor.h"
#include "xcb_cursor.h"
+#ifdef O_CLOEXEC
+#define FOPEN_CLOEXEC "e"
+#else
+#define FOPEN_CLOEXEC ""
+#define O_CLOEXEC 0
+#endif
+
static const char *cursor_path(struct xcb_cursor_context_t *c) {
if (c->path == NULL) {
c->path = getenv("XCURSOR_PATH");
@@ -76,7 +83,7 @@ _XcursorThemeInherits (const char *full)
if (!full)
return NULL;
- f = fopen (full, "r");
+ f = fopen (full, "r" FOPEN_CLOEXEC);
if (f)
{
while (fgets (line, sizeof (line), f))
@@ -155,7 +162,7 @@ static int open_cursor_file(xcb_cursor_context_t *c, const char *theme, const ch
free(themedir);
return -1;
}
- fd = open(full, O_RDONLY);
+ fd = open(full, O_RDONLY | O_CLOEXEC);
free(full);
if (fd == -1 && inherits == NULL) {
if (asprintf(&full, "%s/index.theme", themedir) == -1) {