Merge pull request #1585 from hxy7yx/v2.6-2

verify that the length of modbus bytes point is even
This commit is contained in:
fengzeroz
2023-10-11 15:07:03 +08:00
committed by GitHub
2 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -168,7 +168,8 @@ int modbus_tag_to_point(const neu_datatag_t *tag, modbus_point_t *point)
point->area == MODBUS_AREA_INPUT) {
ret = NEU_ERR_TAG_TYPE_NOT_SUPPORT;
} else {
if (point->option.bytes.length > 128) {
if (point->option.bytes.length > 128 ||
point->option.bytes.length % 2 == 1) {
return NEU_ERR_TAG_ADDRESS_FORMAT_INVALID;
}
point->n_register =
+4 -2
View File
@@ -152,8 +152,10 @@ int modbus_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group,
{
modbus_point_t *p = calloc(1, sizeof(modbus_point_t));
int ret = modbus_tag_to_point(tag, p);
assert(ret == 0);
if (ret != NEU_ERR_SUCCESS) {
plog_error(plugin, "invalid tag: %s, address: %s", tag->name,
tag->address);
}
utarray_push_back(gd->tags, &p);
}