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

Commit 55a9b1e2 authored by Bart Van Assche's avatar Bart Van Assche
Browse files

Fix the stat() return value check in createProcessGroupInternal()



From the stat() man page: "RETURN VALUE On success, zero is returned.
On error, -1 is returned, and errno is set appropriately." Hence check
for failure by checking whether the return value is negative instead of
1.

Bug: 213617178
Test: Booted Android in Cuttlefish and inspected logcat.
Fixes: 9e628a6b ("libprocessgroup: fix uid/pid hierarchy for recovery mode")
Change-Id: I774d142058b083403d32b3f6aae4a4b3de00192c
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent 3d0143dc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ static int createProcessGroupInternal(uid_t uid, int initialPid, std::string cgr
    gid_t cgroup_gid = AID_SYSTEM;
    int ret = 0;

    if (stat(cgroup.c_str(), &cgroup_stat) == 1) {
    if (stat(cgroup.c_str(), &cgroup_stat) < 0) {
        PLOG(ERROR) << "Failed to get stats for " << cgroup;
    } else {
        cgroup_mode = cgroup_stat.st_mode;