This commit is contained in:
jebrando 2018-08-30 17:59:04 -07:00
Родитель 9925c6010f
Коммит 300ecd89da
3 изменённых файлов: 19 добавлений и 10 удалений

Просмотреть файл

@ -3730,7 +3730,7 @@ result = AGENT_DATA_TYPES_OK;
result = AGENT_DATA_TYPES_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(AGENT_DATA_TYPES_RESULT, result));
}
else if (strncpy_s(temp, strLength - 1, source + 1, strLength - 2) != 0)
else if (memcpy(temp, source + 1, strLength - 2) == NULL)
{
free(temp);
@ -3739,8 +3739,8 @@ result = AGENT_DATA_TYPES_OK;
}
else
{
// Removes the "
temp[strLength - 2] = 0;
agentData->type = EDM_STRING_TYPE;
agentData->value.edmString.chars = temp;
agentData->value.edmString.length = strLength - 2;

Просмотреть файл

@ -181,6 +181,12 @@ static EXECUTE_COMMAND_RESULT DecodeAndExecuteModelAction(COMMAND_DECODER_HANDLE
LogError("Invalid action name");
result = EXECUTE_COMMAND_ERROR;
}
if (strLength >= 128)
{
/* Codes_SRS_COMMAND_DECODER_99_021:[ If the parsing of the command fails for any other reason the command shall not be dispatched.] */
LogError("Invalid action name length");
result = EXECUTE_COMMAND_ERROR;
}
else
{
/* Codes_SRS_COMMAND_DECODER_99_006:[ The action name shall be decoded from the element "Name" of the command JSON.] */
@ -188,10 +194,7 @@ static EXECUTE_COMMAND_RESULT DecodeAndExecuteModelAction(COMMAND_DECODER_HANDLE
size_t argCount;
MULTITREE_HANDLE parametersTreeNode;
#ifdef _MSC_VER
#pragma warning(suppress: 6324) /* We intentionally use here strncpy */
#endif
if (memcpy(tempStr, actionName, strLength - 1) == NULL)
if (memcpy(tempStr, actionName, strLength-1) == NULL)
{
/* Codes_SRS_COMMAND_DECODER_99_021:[ If the parsing of the command fails for any other reason the command shall not be dispatched.] */
LogError("Invalid action name.");
@ -206,8 +209,7 @@ static EXECUTE_COMMAND_RESULT DecodeAndExecuteModelAction(COMMAND_DECODER_HANDLE
}
else
{
tempStr[strLength - 1] = 0;
tempStr[strLength-1] = 0;
/* Codes_SRS_COMMAND_DECODER_99_009:[ CommandDecoder shall call Schema_GetModelActionByName to obtain the information about a specific action.] */
if (((modelActionHandle = Schema_GetModelActionByName(modelHandle, tempStr)) == NULL) ||
(Schema_GetModelActionArgumentCount(modelActionHandle, &argCount) != SCHEMA_OK))

Просмотреть файл

@ -289,14 +289,21 @@ MULTITREE_RESULT MultiTree_AddLeaf(MULTITREE_HANDLE treeHandle, const char* dest
/*if there's more or 1 delimiter in the path... */
/*Codes_SRS_MULTITREE_99_017:[ Subsequent names designate hierarchical children in the tree. The last child designates the child that will receive the value.]*/
char firstInnerNodeName[INNER_NODE_NAME_SIZE];
if (strncpy_s(firstInnerNodeName, INNER_NODE_NAME_SIZE, destinationPath, whereIsDelimiter - destinationPath) != 0)
if ((whereIsDelimiter - destinationPath) >= INNER_NODE_NAME_SIZE)
{
/*Codes_SRS_MULTITREE_99_025:[ The function shall return MULTITREE_ERROR to indicate any other error not specified here.]*/
result = MULTITREE_ERROR;
LogError("(result = %s)", ENUM_TO_STRING(MULTITREE_RESULT, result));
LogError("Destination path is too large %d", whereIsDelimiter - destinationPath);
}
else if (memcpy(firstInnerNodeName, destinationPath, whereIsDelimiter - destinationPath) == NULL)
{
/*Codes_SRS_MULTITREE_99_025:[ The function shall return MULTITREE_ERROR to indicate any other error not specified here.]*/
result = MULTITREE_ERROR;
LogError("(result = MULTITREE_ERROR)");
}
else
{
firstInnerNodeName[whereIsDelimiter - destinationPath] = 0;
MULTITREE_HANDLE_DATA *child = getChildByName(node, firstInnerNodeName);
if (child == NULL)
{