mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Don't compare past '\0' in StringView::operator==(const char*)
We kept scanning the needle string even after hitting a null terminator and that's clearly not right. Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31338 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31351
This commit is contained in:
parent
9bc3c3c962
commit
42133a196a
Notes:
sideshowbarker
2024-07-18 21:56:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/42133a196a0
1 changed files with 2 additions and 0 deletions
|
@ -147,6 +147,8 @@ public:
|
|||
// NOTE: `m_characters` is not guaranteed to be null-terminated, but `cstring` is.
|
||||
const char* cp = cstring;
|
||||
for (size_t i = 0; i < m_length; ++i) {
|
||||
if (!*cp)
|
||||
return false;
|
||||
if (m_characters[i] != *(cp++))
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue