Fixed a regression in the rpm_ack_object_property_process() function that prevented proper parsing of multi-object ReadPropertyMultiple ACK responses. The bug was introduced in PR #765 and caused the function to incorrectly return ERROR_CODE_INVALID_TAG after processing the first object, even when additional valid objects were present in the response. Added tests that use rpm_ack_object_property_process() with a multi-object RPM ACK to verify the fix and prevent regression. (#1183)

This commit is contained in:
Steve Karg
2025-12-09 13:18:52 -06:00
committed by GitHub
parent 2b328266c8
commit 7f2690fd96
3 changed files with 226 additions and 10 deletions
+25 -9
View File
@@ -107,6 +107,30 @@ int rpm_encode_apdu_object_end(uint8_t *apdu)
return apdu_len;
}
/**
* @brief Initialize an array (or single) #BACNET_READ_ACCESS_DATA linked list.
* @param data - one or more #BACNET_READ_ACCESS_DATA elements
* @param count - number of #BACNET_READ_ACCESS_DATA elements
*/
void bacnet_read_access_data_init(BACNET_READ_ACCESS_DATA *data, size_t count)
{
size_t i = 0;
if (data && count) {
for (i = 0; i < count; i++) {
data->object_type = OBJECT_NONE;
data->object_instance = 0;
data->listOfProperties = NULL;
if ((i + 1) < count) {
data->next = data + 1;
} else {
data->next = NULL;
}
data++;
}
}
}
/**
* @brief Encode the ReadPropertyMultiple-Request
* @param apdu application data unit buffer for encoding, or NULL for length
@@ -692,15 +716,7 @@ void rpm_ack_object_property_process(
if (bacnet_is_closing_tag_number(apdu, apdu_len, 1, &len)) {
/* end of list-of-results [1] SEQUENCE OF SEQUENCE */
apdu_len -= len;
if (apdu_len > 0) {
/* malformed */
rp_data->error_class = ERROR_CLASS_SERVICES;
rp_data->error_code = ERROR_CODE_INVALID_TAG;
if (callback) {
callback(device_id, rp_data);
}
return;
}
apdu += len;
break;
}
len = rpm_ack_decode_object_property(
+2
View File
@@ -86,6 +86,8 @@ int rpm_encode_apdu_object_property(
BACNET_STACK_EXPORT
int rpm_encode_apdu_object_end(uint8_t *apdu);
BACNET_STACK_EXPORT
void bacnet_read_access_data_init(BACNET_READ_ACCESS_DATA *data, size_t count);
BACNET_STACK_EXPORT
int read_property_multiple_request_encode(
uint8_t *apdu, BACNET_READ_ACCESS_DATA *data);