From df1bf4fe528a5a9eef420f78efb225e4696ac467 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 25 Mar 2023 12:44:39 -0700 Subject: Set close-on-exec when opening files Signed-off-by: Alan Coopersmith --- AuGetAddr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'AuGetAddr.c') diff --git a/AuGetAddr.c b/AuGetAddr.c index 6f5fe16..6de2be3 100644 --- a/AuGetAddr.c +++ b/AuGetAddr.c @@ -30,6 +30,12 @@ in this Software without prior written authorization from The Open Group. #include #include +#ifdef O_CLOEXEC +#define FOPEN_CLOEXEC "e" +#else +#define FOPEN_CLOEXEC "" +#endif + #define binaryEqual(a, b, len) (memcmp(a, b, len) == 0) Xauth * @@ -64,7 +70,7 @@ _Xconst char* name) return NULL; if (access (auth_name, R_OK) != 0) /* checks REAL id */ return NULL; - auth_file = fopen (auth_name, "rb"); + auth_file = fopen (auth_name, "rb" FOPEN_CLOEXEC); if (!auth_file) return NULL; for (;;) { -- cgit v1.2.1