From c41b838baa7f411ec18e0e3d900ad2a9828f1b5e Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 18 Aug 2017 14:43:52 -0700 Subject: [PATCH] Fix use-after-free of stack-allocated temporary string. Bug: 64848081 Test: built and successfully booted again Merged-In: I93c899249bf2cc5ab8d880c0eaff471518e73121 Change-Id: I93c899249bf2cc5ab8d880c0eaff471518e73121 --- init/selinux.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init/selinux.cpp b/init/selinux.cpp index 291b969f2..c8240286d 100644 --- a/init/selinux.cpp +++ b/init/selinux.cpp @@ -295,13 +295,15 @@ bool LoadSplitPolicy() { return false; } std::string mapping_file("/system/etc/selinux/mapping/" + vend_plat_vers + ".cil"); + const std::string version_as_string = std::to_string(max_policy_version); + // clang-format off const char* compile_args[] = { "/system/bin/secilc", plat_policy_cil_file, "-M", "true", "-G", "-N", // Target the highest policy language version supported by the kernel - "-c", std::to_string(max_policy_version).c_str(), + "-c", version_as_string.c_str(), mapping_file.c_str(), "/vendor/etc/selinux/nonplat_sepolicy.cil", "-o", compiled_sepolicy,