Bugfix/deprecate decode tag number and value (#481)

* added or updated secure the BACnet primitive value decoders - the core codecs - named bacnet_x_decode(), bacnet_x_application_decode() and bacnet_x_context_decode where x is one of the 13 BACnet primitive value names.  The updated API includes an APDU size to prevent over-reading of an APDU buffer while decoding.  Improved or added unit test code coverage for the BACnet primitive value decoders.

* marked the insecure decoding API as 'deprecated' which is defined in src/bacnet/basic/sys/platform.h and can be disabled during a build. 

* added secure decoders for BACnetTimeValue, BACnetHostNPort, BACnetTimeStamp, BACnetAddress, and Weekly_Schedule and improved unit test code coverage.

* improved test code coverage for BACnet objects and properties.

* secured AtomicReadFile and AtomicWriteFile service decoders and improved unit test code coverage.

* secured BACnet Error service decoder and improved unit test code coverage.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2023-09-08 11:39:27 -05:00
committed by GitHub
parent bc8c261153
commit f641aacddb
67 changed files with 6103 additions and 3145 deletions
@@ -28,17 +28,19 @@ static void testAccessCredential(void)
uint8_t apdu[MAX_APDU] = { 0 };
int len = 0;
int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = {0};
BACNET_APPLICATION_DATA_VALUE value = {0};
BACNET_APPLICATION_DATA_VALUE value2 = {0};
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = { 0 };
BACNET_APPLICATION_DATA_VALUE value2 = { 0 };
const int *required_property = NULL;
bool status = false;
Access_Credential_Init();
rpdata.application_data = &apdu[0];
rpdata.application_data_len = sizeof(apdu);
rpdata.object_type = OBJECT_ACCESS_CREDENTIAL;
rpdata.object_instance = Access_Credential_Index_To_Instance(0);
status = Access_Credential_Valid_Instance(rpdata.object_instance);
zassert_true(status, NULL);
Access_Credential_Property_Lists(&required_property, NULL, NULL);
while ((*required_property) >= 0) {
rpdata.object_property = *required_property;
@@ -54,7 +56,7 @@ static void testAccessCredential(void)
rpdata.application_data, len, &value);
if (test_len < len) {
test_len += bacapp_decode_application_data(
rpdata.application_data+test_len, len-test_len,
rpdata.application_data + test_len, len - test_len,
&value2);
}
}
@@ -79,9 +81,8 @@ ZTEST_SUITE(access_credential_tests, NULL, NULL, NULL, NULL, NULL);
#else
void test_main(void)
{
ztest_test_suite(access_credential_tests,
ztest_unit_test(testAccessCredential)
);
ztest_test_suite(
access_credential_tests, ztest_unit_test(testAccessCredential));
ztest_run_test_suite(access_credential_tests);
}