[ip6] add additional parse validation to Ip6::Address::FromString (#3843)

This commit is contained in:
Jonathan Hui
2019-05-20 20:37:19 -07:00
committed by GitHub
parent 607f7711e6
commit 8bb50d4ccd
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -316,6 +316,9 @@ otError Address::FromString(const char *aBuf)
// Do not count bytes of the embedded IPv4 address.
endp -= kIp4AddressSize;
VerifyOrExit(dst <= endp, error = OT_ERROR_PARSE);
break;
}
else
+7
View File
@@ -189,6 +189,13 @@ void TestIp6AddressFromString(void)
{0},
OT_ERROR_PARSE
},
// Invalid embedded IPv4 address.
{
":f:0:0:c:0:f:f:.",
{0},
OT_ERROR_PARSE
},
};
for (uint32_t index = 0; index < OT_ARRAY_LENGTH(testVectors); index++)