mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
verify that the length of modbus bytes point is even
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -152,7 +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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user