mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-12 17:37:53 +03:00
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.
This commit is contained in:
parent
419e886497
commit
d7734bf232
Notes:
sideshowbarker
2024-07-19 13:44:39 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/d7734bf232f Pull-request: https://github.com/SerenityOS/serenity/pull/194 Reviewed-by: https://github.com/awesomekling
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user