[message] avoid length overflow in SetLength() (#3418)

Credit to OSS-Fuzz.
This commit is contained in:
Jonathan Hui
2018-12-28 17:27:25 -08:00
committed by GitHub
parent 4b1070444d
commit 08247dc92f
+2
View File
@@ -331,6 +331,8 @@ otError Message::SetLength(uint16_t aLength)
uint16_t totalLengthCurrent = GetReserved() + GetLength();
int bufs = 0;
VerifyOrExit(totalLengthRequest >= GetReserved(), error = OT_ERROR_INVALID_ARGS);
if (totalLengthRequest > kHeadBufferDataSize)
{
bufs = (((totalLengthRequest - kHeadBufferDataSize) - 1) / kBufferDataSize) + 1;