Added test for a decoding problem where the stack is unable to decode something, and retrofitted into WriteProperty for each of the demo objects by returning an Error, Out of Range.

This commit is contained in:
skarg
2010-10-12 01:17:50 +00:00
parent df2a5ca695
commit e9249b5b5e
29 changed files with 221 additions and 83 deletions
+6 -1
View File
@@ -1345,7 +1345,12 @@ static bool Device_Write_Property_Local(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
status =
+6 -1
View File
@@ -414,7 +414,12 @@ bool Analog_Output_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -364,7 +364,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -420,7 +420,12 @@ bool Binary_Input_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status =
+6 -1
View File
@@ -357,7 +357,12 @@ bool Binary_Output_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -340,7 +340,12 @@ bool Binary_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -1232,8 +1232,13 @@ static bool Device_Write_Property_Local(
len =
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
status =
+6 -1
View File
@@ -939,7 +939,12 @@ bool Load_Control_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
object_index = Load_Control_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_REQUESTED_SHED_LEVEL:
+6 -1
View File
@@ -522,7 +522,12 @@ bool Lighting_Output_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -309,7 +309,12 @@ bool Life_Safety_Point_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_MODE:
status =
+6 -1
View File
@@ -469,7 +469,12 @@ bool Multistate_Input_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status =
+6 -1
View File
@@ -356,7 +356,12 @@ bool Multistate_Output_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
+6 -2
View File
@@ -466,8 +466,12 @@ bool Trend_Log_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_ENABLE:
status =
+6 -1
View File
@@ -342,7 +342,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -251,7 +251,12 @@ bool Binary_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -819,7 +819,12 @@ bool Device_Write_Property_Local(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
+6 -1
View File
@@ -182,7 +182,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -199,7 +199,12 @@ bool Binary_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -370,7 +370,12 @@ bool Device_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
+6 -1
View File
@@ -182,7 +182,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -199,7 +199,12 @@ bool Binary_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -332,7 +332,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status =
+6 -1
View File
@@ -393,7 +393,12 @@ bool Binary_Output_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status =
+6 -1
View File
@@ -803,7 +803,12 @@ bool Device_Write_Property_Local(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
+6 -1
View File
@@ -307,7 +307,12 @@ bool Analog_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_REAL) {
+6 -1
View File
@@ -218,7 +218,12 @@ bool Binary_Value_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
+6 -1
View File
@@ -500,7 +500,12 @@ bool Device_Write_Property(
bacapp_decode_application_data(wp_data->application_data,
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
/* FIXME: len == 0: unable to decode? */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
+10 -5
View File
@@ -261,6 +261,7 @@ int bacapp_decode_data(
if (len == 0 && tag_data_type != BACNET_APPLICATION_TAG_NULL &&
tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) {
/* indicate that we were not able to decode the value */
value->tag = MAX_BACNET_APPLICATION_TAG;
}
return len;
@@ -273,6 +274,7 @@ int bacapp_decode_application_data(
{
int len = 0;
int tag_len = 0;
int decode_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
@@ -286,9 +288,13 @@ int bacapp_decode_application_data(
if (tag_len) {
len += tag_len;
value->tag = tag_number;
len +=
bacapp_decode_data(&apdu[len], tag_number, len_value_type,
value);
decode_len = bacapp_decode_data(&apdu[len], tag_number,
len_value_type, value);
if (value->tag != MAX_BACNET_APPLICATION_TAG) {
len += decode_len;
} else {
len = BACNET_STATUS_ERROR;
}
}
value->next = NULL;
}
@@ -627,8 +633,7 @@ int bacapp_decode_context_data(
len_value_type, value);
apdu_len += len;
} else {
/* FIXME: what now? */
apdu_len = 0;
apdu_len = BACNET_STATUS_ERROR;
}
}
value->next = NULL;
+49 -50
View File
@@ -325,7 +325,7 @@ int decode_tag_number(
return len;
}
/* Same as function above, but will safely fail is packet has been truncated */
/* Same as function above, but will safely fail if packet has been truncated */
int decode_tag_number_safe(
uint8_t * apdu,
uint32_t apdu_len_remaining,
@@ -351,7 +351,6 @@ int decode_tag_number_safe(
return len;
}
bool decode_is_opening_tag(
uint8_t * apdu)
{
@@ -580,7 +579,7 @@ int decode_context_boolean2(
}
len++;
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -694,7 +693,7 @@ int decode_context_bitstring(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
len += decode_bitstring(&apdu[len], len_value, bit_string);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -804,7 +803,7 @@ int decode_context_object_id(
if (decode_is_context_tag_with_length(&apdu[len], tag_number, &len)) {
len += decode_object_id(&apdu[len], object_type, instance);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -977,7 +976,7 @@ int decode_context_octet_string(
len += len_value;
}
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
@@ -1087,7 +1086,7 @@ int decode_context_character_string(
len += len_value;
}
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
@@ -1140,7 +1139,7 @@ int decode_context_unsigned(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
len += decode_unsigned(&apdu[len], len_value, value);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1246,7 +1245,7 @@ int decode_context_enumerated(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
len += decode_enumerated(&apdu[len], len_value, value);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1350,7 +1349,7 @@ int decode_context_signed(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
len += decode_signed(&apdu[len], len_value, value);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1581,7 +1580,7 @@ int decode_application_time(
len++;
len += decode_bacnet_time(&apdu[len], btime);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1597,7 +1596,7 @@ int decode_context_bacnet_time(
if (decode_is_context_tag_with_length(&apdu[len], tag_number, &len)) {
len += decode_bacnet_time(&apdu[len], btime);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1626,7 +1625,7 @@ int encode_bacnet_date(
/*
** Don't try and guess what the user meant here. Just fail
*/
return -1;
return BACNET_STATUS_ERROR;
}
@@ -1715,7 +1714,7 @@ int decode_application_date(
len++;
len += decode_date(&apdu[len], bdate);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -1730,7 +1729,7 @@ int decode_context_date(
if (decode_is_context_tag_with_length(&apdu[len], tag_number, &len)) {
len += decode_date(&apdu[len], bdate);
} else {
len = -1;
len = BACNET_STATUS_ERROR;
}
return len;
}
@@ -2389,7 +2388,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_unsigned(apdu, large_context_tag, in);
outLen = decode_context_unsigned(apdu, large_context_tag, &out);
@@ -2397,7 +2396,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 16 bit number */
in = 0xdead;
@@ -2413,7 +2412,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 8 bit number */
in = 0xde;
inLen = encode_context_unsigned(apdu, 10, in);
@@ -2428,7 +2427,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 4 bit number */
in = 0xd;
inLen = encode_context_unsigned(apdu, 10, in);
@@ -2443,7 +2442,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 2 bit number */
in = 0x2;
inLen = encode_context_unsigned(apdu, 10, in);
@@ -2458,7 +2457,7 @@ void testUnsignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
@@ -2484,7 +2483,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_signed(apdu, large_context_tag, in);
outLen = decode_context_signed(apdu, large_context_tag, &out);
@@ -2492,7 +2491,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 16 bit number */
in = 0xdead;
@@ -2508,7 +2507,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 8 bit number */
in = 0xde;
@@ -2524,7 +2523,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 4 bit number */
in = 0xd;
@@ -2540,7 +2539,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 2 bit number */
in = 0x2;
@@ -2556,7 +2555,7 @@ void testSignedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
@@ -2581,7 +2580,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_enumerated(apdu, large_context_tag, in);
outLen = decode_context_enumerated(apdu, large_context_tag, &out);
@@ -2589,7 +2588,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 16 bit number */
in = 0xdead;
@@ -2605,7 +2604,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 8 bit number */
in = 0xde;
inLen = encode_context_enumerated(apdu, 10, in);
@@ -2620,7 +2619,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 4 bit number */
in = 0xd;
inLen = encode_context_enumerated(apdu, 10, in);
@@ -2635,7 +2634,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
/* 2 bit number */
in = 0x2;
inLen = encode_context_enumerated(apdu, 10, in);
@@ -2650,7 +2649,7 @@ void testEnumeratedContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
void testFloatContextDecodes(
@@ -2674,7 +2673,7 @@ void testFloatContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_real(apdu, large_context_tag, in);
outLen = decode_context_real(apdu, large_context_tag, &out);
@@ -2682,7 +2681,7 @@ void testFloatContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
in = 0.0f;
inLen = encode_context_real(apdu, 10, in);
@@ -2698,7 +2697,7 @@ void testFloatContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
void testDoubleContextDecodes(
@@ -2722,7 +2721,7 @@ void testDoubleContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_double(apdu, large_context_tag, in);
outLen = decode_context_double(apdu, large_context_tag, &out);
@@ -2730,7 +2729,7 @@ void testDoubleContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
in = 0.0;
inLen = encode_context_double(apdu, 10, in);
@@ -2746,7 +2745,7 @@ void testDoubleContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in == out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
void testObjectIDContextDecodes(
@@ -2775,7 +2774,7 @@ void testObjectIDContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in_type == out_type);
ct_test(pTest, in_id == out_id);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
inLen = encode_context_object_id(apdu, large_context_tag, in_type, in_id);
outLen =
@@ -2787,7 +2786,7 @@ void testObjectIDContextDecodes(
ct_test(pTest, inLen == outLen);
ct_test(pTest, in_type == out_type);
ct_test(pTest, in_id == out_id);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
}
void testCharacterStringContextDecodes(
@@ -2809,7 +2808,7 @@ void testCharacterStringContextDecodes(
outLen = decode_context_character_string(apdu, 10, &out);
outLen2 = decode_context_character_string(apdu, 9, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.length == out.length);
ct_test(pTest, in.encoding == out.encoding);
@@ -2820,7 +2819,7 @@ void testCharacterStringContextDecodes(
outLen2 =
decode_context_character_string(apdu, large_context_tag - 1, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.length == out.length);
ct_test(pTest, in.encoding == out.encoding);
@@ -2851,7 +2850,7 @@ void testBitStringContextDecodes(
outLen = decode_context_bitstring(apdu, 10, &out);
outLen2 = decode_context_bitstring(apdu, 9, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.bits_used == out.bits_used);
ct_test(pTest, memcmp(in.value, out.value, MAX_BITSTRING_BYTES) == 0);
@@ -2860,7 +2859,7 @@ void testBitStringContextDecodes(
outLen = decode_context_bitstring(apdu, large_context_tag, &out);
outLen2 = decode_context_bitstring(apdu, large_context_tag - 1, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.bits_used == out.bits_used);
ct_test(pTest, memcmp(in.value, out.value, MAX_BITSTRING_BYTES) == 0);
@@ -2887,7 +2886,7 @@ void testOctetStringContextDecodes(
outLen = decode_context_octet_string(apdu, 10, &out);
outLen2 = decode_context_octet_string(apdu, 9, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.length == out.length);
ct_test(pTest, octetstring_value_same(&in, &out));
@@ -2896,7 +2895,7 @@ void testOctetStringContextDecodes(
outLen = decode_context_octet_string(apdu, large_context_tag, &out);
outLen2 = decode_context_octet_string(apdu, large_context_tag - 1, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.length == out.length);
ct_test(pTest, octetstring_value_same(&in, &out));
@@ -2924,7 +2923,7 @@ void testTimeContextDecodes(
outLen = decode_context_bacnet_time(apdu, 10, &out);
outLen2 = decode_context_bacnet_time(apdu, 9, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.hour == out.hour);
ct_test(pTest, in.hundredths == out.hundredths);
@@ -2935,7 +2934,7 @@ void testTimeContextDecodes(
outLen = decode_context_bacnet_time(apdu, large_context_tag, &out);
outLen2 = decode_context_bacnet_time(apdu, large_context_tag - 1, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.hour == out.hour);
ct_test(pTest, in.hundredths == out.hundredths);
@@ -2967,7 +2966,7 @@ void testDateContextDecodes(
outLen = decode_context_date(apdu, 10, &out);
outLen2 = decode_context_date(apdu, 9, &out);
ct_test(pTest, outLen2 == -1);
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
ct_test(pTest, inLen == outLen);
ct_test(pTest, in.day == out.day);
ct_test(pTest, in.month == out.month);