From 159efe77c07abbd38f3afc754d6a644f1a14d64e Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 12 Feb 2021 11:25:58 -0800 Subject: [PATCH] [coap-message] fix buffer overflow in AppendUintOption() (#6163) --- src/core/coap/coap_message.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/coap/coap_message.cpp b/src/core/coap/coap_message.cpp index 23d9cbd52..22c846c77 100644 --- a/src/core/coap/coap_message.cpp +++ b/src/core/coap/coap_message.cpp @@ -200,7 +200,7 @@ otError Message::AppendUintOption(uint16_t aNumber, uint32_t aValue) Encoding::BigEndian::WriteUint32(aValue, buffer); - while (value[0] == 0 && length > 0) + while ((length > 0) && (value[0] == 0)) { value++; length--;