mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
udp: disallow announce requests with port value of 0
This commit is contained in:
parent
c48a83b06a
commit
97688ed074
2 changed files with 11 additions and 4 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
|
||||||
* Quit whole application if any worker thread quits
|
* Quit whole application if any worker thread quits
|
||||||
|
* Disallow announce requests with port value of 0
|
||||||
|
|
||||||
### aquatic_http
|
### aquatic_http
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,21 @@ impl Request {
|
||||||
let request = AnnounceRequest::read_from_prefix(bytes)
|
let request = AnnounceRequest::read_from_prefix(bytes)
|
||||||
.ok_or_else(|| RequestParseError::unsendable_text("invalid data"))?;
|
.ok_or_else(|| RequestParseError::unsendable_text("invalid data"))?;
|
||||||
|
|
||||||
// Make sure not to create AnnounceEventBytes with invalid value
|
if request.port.0.get() == 0 {
|
||||||
if matches!(request.event.0.get(), (0..=3)) {
|
Err(RequestParseError::sendable_text(
|
||||||
Ok(Request::Announce(request))
|
"Port can't be 0",
|
||||||
} else {
|
request.connection_id,
|
||||||
|
request.transaction_id,
|
||||||
|
))
|
||||||
|
} else if !matches!(request.event.0.get(), (0..=3)) {
|
||||||
|
// Make sure not to allow AnnounceEventBytes with invalid value
|
||||||
Err(RequestParseError::sendable_text(
|
Err(RequestParseError::sendable_text(
|
||||||
"Invalid announce event",
|
"Invalid announce event",
|
||||||
request.connection_id,
|
request.connection_id,
|
||||||
request.transaction_id,
|
request.transaction_id,
|
||||||
))
|
))
|
||||||
|
} else {
|
||||||
|
Ok(Request::Announce(request))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Scrape
|
// Scrape
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue