Bugfix/property array element zero size (#908)
* Changed BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers. * Changed the basic and example objects after refactoring BACnetARRAY index validation into ReadProperty, ReadPropertyMultiple, WriteProperty, and WritePropertyMultiple handlers. * Added BACnet application decoder that understands that an array element of zero is an unsigned integer tagged value. Fixes RP and RPM apps when reading the array element zero of arrays.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "bacnet/bacdef.h"
|
||||
/* BACnet Stack API */
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacnet/proplist.h"
|
||||
#include "bacnet/wp.h"
|
||||
|
||||
/** @file wp.c Encode/Decode BACnet Write Property APDUs */
|
||||
@@ -426,6 +427,29 @@ bool write_property_empty_string_valid(
|
||||
return (valid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief simple validation of BACnetARRAY for Write Property
|
||||
* @param data - #BACNET_WRITE_PROPERTY_DATA data, including
|
||||
* requested data and space for the reply, or error response.
|
||||
* @return true if the property is an array and the request uses array
|
||||
* indices.
|
||||
*/
|
||||
bool write_property_bacnet_array_valid(BACNET_WRITE_PROPERTY_DATA *data)
|
||||
{
|
||||
bool is_array;
|
||||
|
||||
/* only array properties can have array options */
|
||||
is_array = property_list_bacnet_array_member(
|
||||
data->object_type, data->object_property);
|
||||
if (!is_array && (data->array_index != BACNET_ARRAY_ALL)) {
|
||||
data->error_class = ERROR_CLASS_PROPERTY;
|
||||
data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper to decode a WriteProperty unsigned integer and set a property
|
||||
* @param wp_data - #BACNET_WRITE_PROPERTY_DATA data including any
|
||||
|
||||
Reference in New Issue
Block a user