mirror of
https://github.com/espressif/openthread.git
synced 2026-09-07 09:40:12 +00:00
[ip6] add additional parse validation to Ip6::Address::FromString (#3830)
This commit is contained in:
@@ -328,6 +328,8 @@ otError Address::FromString(const char *aBuf)
|
||||
VerifyOrExit(++count <= 4, error = OT_ERROR_PARSE);
|
||||
}
|
||||
|
||||
VerifyOrExit(colonp || dst == endp, error = OT_ERROR_PARSE);
|
||||
|
||||
while (colonp && dst > colonp)
|
||||
{
|
||||
*endp-- = *dst--;
|
||||
|
||||
@@ -169,6 +169,26 @@ void TestIp6AddressFromString(void)
|
||||
OT_ERROR_PARSE
|
||||
},
|
||||
|
||||
// Invalid embedded IPv4 address.
|
||||
{
|
||||
".",
|
||||
{0},
|
||||
OT_ERROR_PARSE
|
||||
},
|
||||
|
||||
// Invalid embedded IPv4 address.
|
||||
{
|
||||
":.",
|
||||
{0},
|
||||
OT_ERROR_PARSE
|
||||
},
|
||||
|
||||
// Invalid embedded IPv4 address.
|
||||
{
|
||||
"::.",
|
||||
{0},
|
||||
OT_ERROR_PARSE
|
||||
},
|
||||
};
|
||||
|
||||
for (uint32_t index = 0; index < OT_ARRAY_LENGTH(testVectors); index++)
|
||||
|
||||
Reference in New Issue
Block a user