summaryrefslogtreecommitdiff
path: root/libs/graphicsenv/IGpuService.cpp
diff options
context:
space:
mode:
author Serdar Kocdemir <kocdemir@google.com> 2023-08-01 18:17:29 +0100
committer Serdar Kocdemir <kocdemir@google.com> 2023-08-01 18:17:29 +0100
commitd6df2edb89026a676c6e0cc609dd5a8cac62fd7c (patch)
tree76649a22b1afaaa9c99835da70dd4c5443235cf8 /libs/graphicsenv/IGpuService.cpp
parentbeb4c56fe8959b09d597bd4355631a7acc49ad99 (diff)
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
Diffstat (limited to 'libs/graphicsenv/IGpuService.cpp')
-rw-r--r--libs/graphicsenv/IGpuService.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp
index 4c070aec01..1c0439ec1e 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -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;
}