From 0cd21d8d3f5c4772db733a256a5b8e96bca173ca Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Thu, 3 Jan 2019 09:16:54 -0800 Subject: [PATCH] [border-agent] check if TLV is valid after reading (#3424) --- src/core/meshcop/border_agent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index 6074f2a0f..3c1675c11 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -203,6 +203,7 @@ void BorderAgent::HandleCoapResponse(void * aContext, StateTlv stateTlv; SuccessOrExit(error = Tlv::GetTlv(*message, Tlv::kState, sizeof(stateTlv), stateTlv)); + VerifyOrExit(stateTlv.IsValid(), error = OT_ERROR_PARSE); if (stateTlv.GetState() == StateTlv::kAccept) { @@ -210,6 +211,7 @@ void BorderAgent::HandleCoapResponse(void * aContext, SuccessOrExit(error = Tlv::GetTlv(*message, Tlv::kCommissionerSessionId, sizeof(sessionIdTlv), sessionIdTlv)); + VerifyOrExit(sessionIdTlv.IsValid(), error = OT_ERROR_PARSE); netif.GetMle().GetCommissionerAloc(borderAgent.mCommissionerAloc.GetAddress(), sessionIdTlv.GetCommissionerSessionId());