mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-05 16:57:53 +00:00
Properly handle incorrect port numbers in parseURL (fixes #4200)
This commit is contained in:
committed by
Nik Bougalis
parent
3172a816fa
commit
d632f9f6c8
@@ -90,6 +90,13 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl)
|
|||||||
if (!port.empty())
|
if (!port.empty())
|
||||||
{
|
{
|
||||||
pUrl.port = beast::lexicalCast<std::uint16_t>(port);
|
pUrl.port = beast::lexicalCast<std::uint16_t>(port);
|
||||||
|
|
||||||
|
// For inputs larger than 2^32-1 (65535), lexicalCast returns 0.
|
||||||
|
// parseUrl returns false for such inputs.
|
||||||
|
if (pUrl.port == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pUrl.path = smMatch[6];
|
pUrl.path = smMatch[6];
|
||||||
|
|
||||||
|
|||||||
@@ -289,6 +289,13 @@ public:
|
|||||||
BEAST_EXPECT(!parseUrl(pUrl, "nonsense"));
|
BEAST_EXPECT(!parseUrl(pUrl, "nonsense"));
|
||||||
BEAST_EXPECT(!parseUrl(pUrl, "://"));
|
BEAST_EXPECT(!parseUrl(pUrl, "://"));
|
||||||
BEAST_EXPECT(!parseUrl(pUrl, ":///"));
|
BEAST_EXPECT(!parseUrl(pUrl, ":///"));
|
||||||
|
BEAST_EXPECT(
|
||||||
|
!parseUrl(pUrl, "scheme://user:pass@domain:65536/abc:321"));
|
||||||
|
BEAST_EXPECT(!parseUrl(pUrl, "UPPER://domain:23498765/"));
|
||||||
|
BEAST_EXPECT(!parseUrl(pUrl, "UPPER://domain:0/"));
|
||||||
|
BEAST_EXPECT(!parseUrl(pUrl, "UPPER://domain:+7/"));
|
||||||
|
BEAST_EXPECT(!parseUrl(pUrl, "UPPER://domain:-7234/"));
|
||||||
|
BEAST_EXPECT(!parseUrl(pUrl, "UPPER://domain:@#$56!/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user