summaryrefslogtreecommitdiff
path: root/netwerk/base
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-04-20 13:12:38 +0000
committerMoonchild <moonchild@palemoon.org>2021-04-20 13:12:38 +0000
commitc8576dce04d4124c9093d2f9bfc341e2e066ad4d (patch)
treebe54a644000ba1eed6cc16e95b9bd40565be26f2 /netwerk/base
parent8e63193c701803f5cfade6afbb4ff0e7ad029ff2 (diff)
downloaduxp-c8576dce04d4124c9093d2f9bfc341e2e066ad4d.tar.gz
[Network] Solve type mismatch in AllowPort().
Casting it to an int16_t was wrong and would preclude the check for high port numbers (due to overflow). This makes the type matching, but adds an explicit check to ensure the port number passed in is within a valid range.
Diffstat (limited to 'netwerk/base')
-rw-r--r--netwerk/base/nsIOService.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp
index a953dc78c1..55f40a41ef 100644
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1203,13 +1203,14 @@ nsIOService::SetConnectivityInternal(bool aConnectivity)
NS_IMETHODIMP
nsIOService::AllowPort(int32_t inPort, const char *scheme, bool *_retval)
{
- int16_t port = inPort;
+ int32_t port = inPort;
if (port == -1) {
*_retval = true;
return NS_OK;
}
- if (port == 0) {
+ // Ensure the port number is within a valid range
+ if (port <= 0 || port >= std::numeric_limits<uint16_t>::max()) {
*_retval = false;
return NS_OK;
}