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]); }