Skip to content

Commit fe01a88

Browse files
committed
Prevent out of bounds check on the password method
1 parent b991fa8 commit fe01a88

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib.rs

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

0 commit comments

Comments
 (0)