mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
url: validate ipv4 part length
PR-URL: https://github.com/nodejs/node/pull/42915 Fixes: https://github.com/nodejs/node/issues/42914 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
committed by
Rich Trott
parent
3d0fc13ba3
commit
87d0d7a069
@@ -411,8 +411,11 @@ void URLHost::ParseIPv4Host(const char* input, size_t length, bool* is_ipv4) {
|
||||
const char ch = pointer < end ? pointer[0] : kEOL;
|
||||
int64_t remaining = end - pointer - 1;
|
||||
if (ch == '.' || ch == kEOL) {
|
||||
if (++parts > static_cast<int>(arraysize(numbers)))
|
||||
// If parts’s size is greater than 4, validation error, return failure.
|
||||
if (++parts > static_cast<int>(arraysize(numbers))) {
|
||||
*is_ipv4 = true;
|
||||
return;
|
||||
}
|
||||
if (pointer == mark)
|
||||
return;
|
||||
int64_t n = ParseNumber(mark, pointer);
|
||||
|
||||
17
test/fixtures/wpt/url/resources/urltestdata.json
vendored
17
test/fixtures/wpt/url/resources/urltestdata.json
vendored
@@ -5317,17 +5317,12 @@
|
||||
{
|
||||
"input": "http://256.256.256.256.256",
|
||||
"base": "http://other.com/",
|
||||
"href": "http://256.256.256.256.256/",
|
||||
"origin": "http://256.256.256.256.256",
|
||||
"protocol": "http:",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"host": "256.256.256.256.256",
|
||||
"hostname": "256.256.256.256.256",
|
||||
"port": "",
|
||||
"pathname": "/",
|
||||
"search": "",
|
||||
"hash": ""
|
||||
"failure": true
|
||||
},
|
||||
{
|
||||
"input": "http://256.256.256.256.256.",
|
||||
"base": "http://other.com/",
|
||||
"failure": true
|
||||
},
|
||||
{
|
||||
"input": "https://0x.0x.0",
|
||||
|
||||
Reference in New Issue
Block a user