From ec3a9f87a7986b28758c064556f8ef779649eb48 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Mon, 31 Aug 2020 08:27:01 -0700 Subject: [PATCH] [posix] fix potential buffer overflow in otPlatDiagProcess() (#5478) --- src/posix/platform/radio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posix/platform/radio.cpp b/src/posix/platform/radio.cpp index 0f21d64e2..721f71100 100644 --- a/src/posix/platform/radio.cpp +++ b/src/posix/platform/radio.cpp @@ -403,7 +403,7 @@ otError otPlatDiagProcess(otInstance *aInstance, char *cur = cmd; char *end = cmd + sizeof(cmd); - for (uint8_t index = 0; index < aArgsLength; index++) + for (uint8_t index = 0; (index < aArgsLength) && (cur < end); index++) { cur += snprintf(cur, static_cast(end - cur), "%s ", aArgs[index]); }