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

Commit d6df2edb authored by Serdar Kocdemir's avatar Serdar Kocdemir
Browse files

Duplicate the file descriptors for shellCommand

Fixes the fdsan issues regarding the ownership of
the file descriptors when running adb gpu commands.

Bug: b/293209452
Test: adb shell cmd gpu vkjson
Change-Id: Ifb624b888706759cf3689dbc34040e08e3d2d70b
parent beb4c56f
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -180,9 +180,9 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep
            return reply->writeUtf8AsUtf16(driverPath);
        }
        case SHELL_COMMAND_TRANSACTION: {
            int in = data.readFileDescriptor();
            int out = data.readFileDescriptor();
            int err = data.readFileDescriptor();
            int in = dup(data.readFileDescriptor());
            int out = dup(data.readFileDescriptor());
            int err = dup(data.readFileDescriptor());

            std::vector<String16> args;
            data.readString16Vector(&args);
@@ -195,6 +195,9 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep

            status = shellCommand(in, out, err, args);
            if (resultReceiver != nullptr) resultReceiver->send(status);
            ::close(in);
            ::close(out);
            ::close(err);

            return OK;
        }