summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-12-08 22:30:17 -0800
committerElliott Hughes <enh@google.com>2020-12-08 22:30:17 -0800
commitd92c6a12dacb4eaf0ab6b40ed4eb18fbf1f11f40 (patch)
treeab1c8edc6f072f3d96e359ea9064576cf45264e7
parent77692aeea28a0781c0c918673ece565c28f15643 (diff)
downloadcore-d92c6a12dacb4eaf0ab6b40ed4eb18fbf1f11f40.tar.gz
Use freecon() with getcon()/getfilecon().
Bug: https://issuetracker.google.com/175090444 Test: treehugger Change-Id: Ia2b8102f1c9a4fd56ec1ff026ba5b4f375102b9b
-rw-r--r--init/service.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/init/service.cpp b/init/service.cpp
index 766eb5d93..d84dcd431 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -72,12 +72,12 @@ static Result<std::string> ComputeContextFromExecutable(const std::string& servi
if (getcon(&raw_con) == -1) {
return Error() << "Could not get security context";
}
- std::unique_ptr<char> mycon(raw_con);
+ std::unique_ptr<char, decltype(&freecon)> mycon(raw_con, freecon);
if (getfilecon(service_path.c_str(), &raw_filecon) == -1) {
return Error() << "Could not get file context";
}
- std::unique_ptr<char> filecon(raw_filecon);
+ std::unique_ptr<char, decltype(&freecon)> filecon(raw_filecon, freecon);
char* new_con = nullptr;
int rc = security_compute_create(mycon.get(), filecon.get(),