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

Commit b00d5467 authored by Jin Qian's avatar Jin Qian
Browse files

storaged: fix crash when cmdline is longer than 64 characters

Bug: 34331490
Change-Id: I40302f4d54b7d8fe4fc5ecbc76df42df68a35504
parent 27506fa4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ struct disk_stats {
    double   io_avg;         // average io_in_flight for accumulate calculations
};

#define MMC_VER_STR_LEN ( 8 )   // maximum length of the MMC version string
#define MMC_VER_STR_LEN ( 9 )   // maximum length of the MMC version string, including NULL terminator
// minimum size of a ext_csd file
#define EXT_CSD_FILE_MIN_SIZE ( 1024 )
struct emmc_info {
+3 −3
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ bool parse_emmc_ecsd(int ext_csd_fd, struct emmc_info* info) {
        "4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0"
    };

    strncpy(info->mmc_ver,
    strlcpy(info->mmc_ver,
            (ext_csd_rev < (int)(sizeof(ver_str) / sizeof(ver_str[0]))) ?
                           ver_str[ext_csd_rev] :
                           "Unknown",
@@ -276,12 +276,12 @@ bool parse_task_info(uint32_t pid, struct task_info* info) {
    // Get cmd string
    std::string task_cmdline_path = android::base::StringPrintf(PROC_DIR "%u/cmdline", pid);
    if (!android::base::ReadFileToString(task_cmdline_path, &buffer)) return false;
    strcpy(info->cmd, android::base::Trim(buffer).c_str());
    strlcpy(info->cmd, android::base::Trim(buffer).c_str(), sizeof(info->cmd));

    if (info->cmd[0] == '\0') {
        std::string task_comm_path = android::base::StringPrintf(PROC_DIR "%u/comm", pid);
        if (!android::base::ReadFileToString(task_comm_path, &buffer)) return false;
        strcpy(info->cmd, android::base::Trim(buffer).c_str());
        strlcpy(info->cmd, android::base::Trim(buffer).c_str(), sizeof(info->cmd));
    }

    // Get task start time