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[3] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */
apdu_len = 4;
len =
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
rpdata->object_instance);
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 1,
rpdata->object_property);
apdu_len += len;
if (rpdata->object_type <= BACNET_MAX_OBJECT) {
/* check bounds so that we could create malformed
messages for testing */
len =
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
rpdata->object_instance);
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 */
if (rpdata->array_index != BACNET_ARRAY_ALL) {
len =