diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-10-08 20:33:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-10-08 20:33:46 +0000 |
commit | 32f5ff0dae56aa8ac7b71b81b8f89021ef9512ee (patch) | |
tree | 4c278dad432b054e1ed1c199314bca7ed7feaf75 | |
parent | ca2d62e1e7875a621f6ad23ea8ee3e024fb6cfd5 (diff) | |
parent | bb12c5e45be79389c40b678aeae338f647310b82 (diff) | |
download | system_core-32f5ff0dae56aa8ac7b71b81b8f89021ef9512ee.tar.gz system_core-32f5ff0dae56aa8ac7b71b81b8f89021ef9512ee.tar.bz2 system_core-32f5ff0dae56aa8ac7b71b81b8f89021ef9512ee.zip |
Merge changes Id6c00c76,Ibc74a12f
* changes:
Check return status of ReadFileToString() in GetDeviceLockStatus()
Validate partition name when searching for physical partitions.
-rw-r--r-- | fastboot/device/utility.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp index 528abec49..b844b9f0a 100644 --- a/fastboot/device/utility.cpp +++ b/fastboot/device/utility.cpp @@ -23,6 +23,7 @@ #include <android-base/file.h> #include <android-base/logging.h> +#include <android-base/strings.h> #include <fs_mgr.h> #include <fs_mgr_dm_linear.h> #include <liblp/liblp.h> @@ -82,6 +83,10 @@ bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHan } std::optional<std::string> FindPhysicalPartition(const std::string& name) { + // Check for an invalid file name + if (android::base::StartsWith(name, "../") || name.find("/../") != std::string::npos) { + return {}; + } std::string path = "/dev/block/by-name/" + name; if (access(path.c_str(), W_OK) < 0) { return {}; @@ -164,6 +169,9 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) { bool GetDeviceLockStatus() { std::string cmdline; - android::base::ReadFileToString("/proc/cmdline", &cmdline); + // Return lock status true if unable to read kernel command line. + if (!android::base::ReadFileToString("/proc/cmdline", &cmdline)) { + return true; + } return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos; } |