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:
+25
-9
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user