Added bounds checking to one of the RP encode to allow for malformed message for negative unit tests.

This commit is contained in:
skarg
2013-03-12 03:59:29 +00:00
parent 4dd04a0489
commit a0e0b81ca4
+16 -8
View File
@@ -55,14 +55,22 @@ int rp_encode_apdu(
apdu[2] = invoke_id; apdu[2] = invoke_id;
apdu[3] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */ apdu[3] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */
apdu_len = 4; apdu_len = 4;
len = if (rpdata->object_type <= BACNET_MAX_OBJECT) {
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type, /* check bounds so that we could create malformed
rpdata->object_instance); messages for testing */
apdu_len += len; len =
len = encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
encode_context_enumerated(&apdu[apdu_len], 1, rpdata->object_instance);
rpdata->object_property); apdu_len += len;
apdu_len += len; }
if (rpdata->object_property <= 4194303) {
/* check bounds so that we could create malformed
messages for testing */
len =
encode_context_enumerated(&apdu[apdu_len], 1,
rpdata->object_property);
apdu_len += len;
}
/* optional array index */ /* optional array index */
if (rpdata->array_index != BACNET_ARRAY_ALL) { if (rpdata->array_index != BACNET_ARRAY_ALL) {
len = len =