diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-06-04 21:55:52 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-04 07:08:07 -0700 |
commit | d7734bf232fd6d23ee3bc2aabe2c9049c45a2016 (patch) | |
tree | 5525dcf218f392540608ab172a4a80c7c6f796fd | |
parent | 419e886497cd9b41fd8f3cb586db48a832c2b176 (diff) | |
download | serenity-d7734bf232fd6d23ee3bc2aabe2c9049c45a2016.zip |
Kernel: Fix KParams parsing with trailing space in kernel cmdline
When there's a trailing space in the cmdline from the boot loader, this
results in an empty string being emitted from `String::split` after
splitting apart the argument list. This empty string resulted in a
zero-length Vector from the subsequent call to split the key=value pairs,
which was unexpected. This ultimately caused a crash when we tried to
access `[0]` of that zero-length vector.
We now detect and handle an empty string coming from `String::split`
correctly.
-rw-r--r-- | Kernel/KParams.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/KParams.cpp b/Kernel/KParams.cpp index 37e3ee7275..26f4df771a 100644 --- a/Kernel/KParams.cpp +++ b/Kernel/KParams.cpp @@ -13,6 +13,10 @@ KParams::KParams(const String& cmdline) s_the = this; for (auto str : m_cmdline.split(' ')) { + if (str == "") { + continue; + } + auto pair = str.split_limit('=', 2); if (pair.size() == 1) { |