From 2708c74ebedb6b3ae814b2badedb158b1edc3c68 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 18 Feb 2019 03:25:21 -0500 Subject: [PATCH] Add O_CLOEXEC to opens --- native/jni/magiskhide/proc_monitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/jni/magiskhide/proc_monitor.cpp b/native/jni/magiskhide/proc_monitor.cpp index aa320e63a..12576f16d 100644 --- a/native/jni/magiskhide/proc_monitor.cpp +++ b/native/jni/magiskhide/proc_monitor.cpp @@ -79,14 +79,14 @@ static inline int parse_ppid(const int pid) { } #endif -static bool is_pid_safetynet_process(const int pid) { +static bool is_snet(const int pid) { char path[32]; char buf[64]; int fd; ssize_t len; sprintf(path, "/proc/%d/cmdline", pid); - fd = open(path, O_RDONLY); + fd = open(path, O_RDONLY | O_CLOEXEC); if (fd == -1) return false; @@ -158,7 +158,7 @@ static bool process_pid(int pid) { if (uid == gms_uid) { // Check /proc/uid/cmdline to see if it's SAFETYNET_PROCESS - if (!is_pid_safetynet_process(pid)) + if (!is_snet(pid)) return true; LOGD("proc_monitor: " SAFETYNET_PROCESS "\n");