mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 15:47:46 +00:00
[cli] fix usage of strncpy in coap (#6908)
This commit is contained in:
@@ -402,8 +402,8 @@ otError Coap::ProcessRequest(Arg aArgs[], otCoapCode aCoapCode)
|
||||
SuccessOrExit(error = aArgs[0].ParseAsIp6Address(coapDestinationIp));
|
||||
|
||||
VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(aArgs[1].GetLength() < kMaxUriLength, error = OT_ERROR_INVALID_ARGS);
|
||||
strncpy(coapUri, aArgs[1].GetCString(), sizeof(coapUri) - 1);
|
||||
VerifyOrExit(aArgs[1].GetLength() < sizeof(coapUri), error = OT_ERROR_INVALID_ARGS);
|
||||
strcpy(coapUri, aArgs[1].GetCString());
|
||||
|
||||
// CoAP-Type
|
||||
if (!aArgs[2].IsEmpty())
|
||||
|
||||
@@ -61,6 +61,7 @@ CoapSecure::CoapSecure(Interpreter &aInterpreter)
|
||||
memset(&mResource, 0, sizeof(mResource));
|
||||
memset(&mPsk, 0, sizeof(mPsk));
|
||||
memset(&mPskId, 0, sizeof(mPskId));
|
||||
memset(&mUriPath, 0, sizeof(mUriPath));
|
||||
strncpy(mResourceContent, "0", sizeof(mResourceContent));
|
||||
mResourceContent[sizeof(mResourceContent) - 1] = '\0';
|
||||
}
|
||||
@@ -249,8 +250,8 @@ otError CoapSecure::ProcessRequest(Arg aArgs[], otCoapCode aCoapCode)
|
||||
#endif
|
||||
|
||||
VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
strncpy(coapUri, aArgs[0].GetCString(), sizeof(coapUri) - 1);
|
||||
VerifyOrExit(aArgs[0].GetLength() < sizeof(coapUri), error = OT_ERROR_INVALID_ARGS);
|
||||
strcpy(coapUri, aArgs[0].GetCString());
|
||||
|
||||
if (!aArgs[1].IsEmpty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user