Skip to content

Commit cc2b3f4

Browse files
committed
Prevent out of bounds check on the password method
1 parent dc9374f commit cc2b3f4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,10 @@ impl Url {
746746
pub fn password(&self) -> Option<&str> {
747747
// This ':' is not the one marking a port number since a host can not be empty.
748748
// (Except for file: URLs, which do not have port numbers.)
749-
if self.has_authority() && self.byte_at(self.username_end) == b':' {
749+
if self.has_authority()
750+
&& self.username_end < self.serialization.len() as u32
751+
&& self.byte_at(self.username_end) == b':'
752+
{
750753
debug_assert!(self.byte_at(self.host_start - 1) == b'@');
751754
Some(self.slice(self.username_end + 1..self.host_start - 1))
752755
} else {

0 commit comments

Comments
 (0)