Merge pull request #1812 from hxy7yx/v2.7-1

fix(add gtag): memory overflow
This commit is contained in:
fengzeroz
2024-01-12 17:03:19 +08:00
committed by GitHub
2 changed files with 105 additions and 3 deletions
+2 -2
View File
@@ -1325,8 +1325,8 @@ int add_gtags(neu_adapter_t *adapter, neu_req_add_gtag_t *cmd,
if (add_tag_result != 0) {
for (int added_group_index = 0; added_group_index < group_index;
added_group_index++) {
for (int added_tag_index = 0; added_tag_index <=
cmd->groups[added_group_index].n_tag;
for (int added_tag_index = 0;
added_tag_index < cmd->groups[added_group_index].n_tag;
added_tag_index++) {
neu_adapter_driver_del_tag(
(neu_adapter_driver_t *) adapter,
+103 -1
View File
@@ -355,4 +355,106 @@ class TestLog:
assert 2 == response.json()['groups'][1]['tag_count']
assert 'group_3' == response.json()['groups'][2]['group']
assert 3000 == response.json()['groups'][2]['interval']
assert 2 == response.json()['groups'][2]['tag_count']
assert 2 == response.json()['groups'][2]['tag_count']
@description(given="multiple groups including same name tags in the first group", when="adding", then="add failed")
def test_adding_same_name_gtags_first_group(self):
response = api.add_gtags(
node='modbus-tcp-tag-test',
groups=[
{
"group": "group_f",
"interval": 3000,
"tags": [
{
"name": "tag1",
"address": "1!400001",
"attribute": 3,
"type": 3,
"decimal": 0.01
},
{
"name": "tag1",
"address": "1!400002",
"attribute": 3,
"type": 9,
"precision": 3
}
]
},
{
"group": "group_s",
"interval": 3000,
"tags": [
{
"name": "tag1",
"address": "1!400001",
"attribute": 3,
"type": 9,
"precision": 3
},
{
"name": "tag2",
"address": "1!400002",
"attribute": 3,
"type": 9,
"precision": 3
}
]
}
]
)
assert 409 == response.status_code
assert NEU_ERR_TAG_NAME_CONFLICT == response.json()['error']
@description(given="multiple groups including same name tags in the second group", when="adding", then="add failed")
def test_adding_same_name_gtags_second_group(self):
response = api.add_gtags(
node='modbus-tcp-tag-test',
groups=[
{
"group": "group_f",
"interval": 3000,
"tags": [
{
"name": "tag1",
"address": "1!400001",
"attribute": 3,
"type": 3,
"decimal": 0.01
},
{
"name": "tag2",
"address": "1!400002",
"attribute": 3,
"type": 9,
"precision": 3
}
]
},
{
"group": "group_s",
"interval": 3000,
"tags": [
{
"name": "tag1",
"address": "1!400001",
"attribute": 3,
"type": 9,
"precision": 3
},
{
"name": "tag1",
"address": "1!400002",
"attribute": 3,
"type": 9,
"precision": 3
}
]
}
]
)
assert 409 == response.status_code
assert NEU_ERR_TAG_NAME_CONFLICT == response.json()['error']