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

Commit 23249c9f authored by Ruslan Trofymenko's avatar Ruslan Trofymenko
Browse files

fs_mgr: Fix kernel command line parsing



Remove new line character ('\n') from the kernel command line after
reading from '/proc/cmdline'. This character is not contained in the
original string and is added as a result of reading (according to
kernel source codes [1]):

    ...
    seq_puts(m, saved_command_line);
    seq_putc(m, '\n');
    ...

As a result, this may corrupt the last argument of the string. For
example, if the last argument is 'androidboot.slot_suffix=_a', then the
target partition ('vendor_a\n') will not be found in fstab section of
the device tree.

[1] fs/proc/cmdline.c

Change-Id: I96a853f1f55f27d782afe2ca8c0b006a75368149
Signed-off-by: default avatarRuslan Trofymenko <ruslan.trofymenko@linaro.org>
parent 1baa19b1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ bool fs_mgr_get_boot_config_from_kernel(const std::string& cmdline, const std::s
bool fs_mgr_get_boot_config_from_kernel_cmdline(const std::string& key, std::string* out_val) {
    std::string cmdline;
    if (!android::base::ReadFileToString("/proc/cmdline", &cmdline)) return false;
    if (!cmdline.empty() && cmdline.back() == '\n') {
        cmdline.pop_back();
    }
    return fs_mgr_get_boot_config_from_kernel(cmdline, key, out_val);
}