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

Commit 32f5ff0d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Id6c00c76,Ibc74a12f

* changes:
  Check return status of ReadFileToString() in GetDeviceLockStatus()
  Validate partition name when searching for physical partitions.
parents ca2d62e1 bb12c5e4
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@


#include <android-base/file.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/logging.h>
#include <android-base/strings.h>
#include <fs_mgr.h>
#include <fs_mgr.h>
#include <fs_mgr_dm_linear.h>
#include <fs_mgr_dm_linear.h>
#include <liblp/liblp.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) {
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;
    std::string path = "/dev/block/by-name/" + name;
    if (access(path.c_str(), W_OK) < 0) {
    if (access(path.c_str(), W_OK) < 0) {
        return {};
        return {};
@@ -164,6 +169,9 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) {


bool GetDeviceLockStatus() {
bool GetDeviceLockStatus() {
    std::string cmdline;
    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;
    return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos;
}
}