mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +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
|
||||
|
||||
* Quit whole application if any worker thread quits
|
||||
* Disallow announce requests with port value of 0
|
||||
|
||||
### aquatic_http
|
||||
|
||||
|
|
|
|||
|
|
@ -58,15 +58,21 @@ impl Request {
|
|||
let request = AnnounceRequest::read_from_prefix(bytes)
|
||||
.ok_or_else(|| RequestParseError::unsendable_text("invalid data"))?;
|
||||
|
||||
// Make sure not to create AnnounceEventBytes with invalid value
|
||||
if matches!(request.event.0.get(), (0..=3)) {
|
||||
Ok(Request::Announce(request))
|
||||
} else {
|
||||
if request.port.0.get() == 0 {
|
||||
Err(RequestParseError::sendable_text(
|
||||
"Port can't be 0",
|
||||
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(
|
||||
"Invalid announce event",
|
||||
request.connection_id,
|
||||
request.transaction_id,
|
||||
))
|
||||
} else {
|
||||
Ok(Request::Announce(request))
|
||||
}
|
||||
}
|
||||
// Scrape
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue