Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51e58ace authored by Bart Van Assche's avatar Bart Van Assche
Browse files

libprocessgroup: Add argument checks in KillProcessGroup()



Apparently there is Java code that calls KillProcessGroup() with an
invalid initialPid argument. Hence this CL that makes KillProcessGroup()
fail early if one of its arguments is invalid.

Change-Id: I42f98eed139d9d0950428d04180e4613ba74b4e6
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent dc8a0b82
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -446,6 +446,14 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid,

static int KillProcessGroup(uid_t uid, int initialPid, int signal, int retries,
                            int* max_processes) {
    if (uid < 0) {
        LOG(ERROR) << __func__ << ": invalid UID " << uid;
        return -1;
    }
    if (initialPid <= 0) {
        LOG(ERROR) << __func__ << ": invalid PID " << initialPid;
        return -1;
    }
    std::string hierarchy_root_path;
    if (CgroupsAvailable()) {
        CgroupGetControllerPath(CGROUPV2_CONTROLLER_NAME, &hierarchy_root_path);