Added bounds checking to one of the RP encode to allow for malformed message for negative unit tests.
This commit is contained in:
+16
-8
@@ -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 =
|
||||||
|
|||||||
Reference in New Issue
Block a user