Skip to content

Commit

Permalink
Merge pull request #1585 from hxy7yx/v2.6-2
Browse files Browse the repository at this point in the history
verify that the length of modbus bytes point is even
  • Loading branch information
fengzeroz authored Oct 11, 2023
2 parents 97cc025 + 75a8cb2 commit db7a59f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion plugins/modbus/modbus_point.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
6 changes: 4 additions & 2 deletions plugins/modbus/modbus_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit db7a59f

Please sign in to comment.