[mpl] validate HBH header length when inserting MPL Option (#2058)

Credit to OSS-Fuzz.
This commit is contained in:
Jonathan Hui
2017-08-03 22:43:30 -07:00
committed by GitHub
parent 2f3cfe1c4c
commit 59b94b4ca7
+2
View File
@@ -174,6 +174,8 @@ otError Ip6::InsertMplOption(Message &aMessage, Header &aIp6Header, MessageInfo
aMessage.Read(0, sizeof(hbh), &hbh);
hbhLength = (hbh.GetLength() + 1) * 8;
VerifyOrExit(hbhLength <= aIp6Header.GetPayloadLength(), error = OT_ERROR_PARSE);
// increase existing hop-by-hop option header length by 8 bytes
hbh.SetLength(hbh.GetLength() + 1);
aMessage.Write(0, sizeof(hbh), &hbh);