Skip to content

Commit

Permalink
Fix minor buffer overflow in url.c++
Browse files Browse the repository at this point in the history
When the protocol string is empty, we should not try to drop a trailing
colon. This was found by using a new fuzzer for URL-related APIs.
  • Loading branch information
fhanau committed Oct 2, 2024
1 parent 015f8e3 commit c2568c1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/workerd/jsg/url.c++
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,9 @@ UrlPattern::Result<UrlPattern::Init> UrlPattern::processInit(
chooseStr(kj::mv(init.protocol), options.protocol).map([](kj::String&& str) mutable {
// It's silly but the URL spec always includes the : suffix in the value,
// while the URLPattern spec always omits it. Silly specs.
if (!str.size()) {
return kj::mv(str);
}
return stripSuffixFromProtocol(str.asPtr());
})) {
result.protocol = kj::mv(protocol);
Expand Down

0 comments on commit c2568c1

Please sign in to comment.