Revised BBMD registration functions to return something approximating a goodness value. (Still too happy for invalid BBMDs, but it's a start.)

Fixed handling of bacapp_decode_context_data() for some of the more unusual (empty, etc) cases I've seen.
This commit is contained in:
tbrennan3
2011-08-22 19:45:41 +00:00
parent 5aaf89c64d
commit a92160f73d
2 changed files with 32 additions and 12 deletions
+11 -3
View File
@@ -694,11 +694,14 @@ int bacapp_decode_context_data(
max_apdu_len = max_apdu_len;
if (apdu && value && IS_CONTEXT_SPECIFIC(*apdu)) {
value->context_specific = true;
value->next = NULL;
tag_len =
decode_tag_number_and_value(&apdu[0], &tag_number,
&len_value_type);
if (tag_len) {
apdu_len = tag_len;
apdu_len = tag_len;
/* Empty construct : (closing tag) => returns NULL value */
if (tag_len && tag_len <= max_apdu_len &&
!decode_is_closing_tag_number(&apdu[0], tag_number)) {
value->context_tag = tag_number;
value->tag = bacapp_context_tag_type(property, tag_number);
if (value->tag < MAX_BACNET_APPLICATION_TAG) {
@@ -706,11 +709,16 @@ int bacapp_decode_context_data(
bacapp_decode_data(&apdu[apdu_len], value->tag,
len_value_type, value);
apdu_len += len;
} else if (len_value_type) {
/* Unknown value : non null size (elementary type) */
apdu_len += len_value_type;
/* SHOULD NOT HAPPEN, EXCEPTED WHEN READING UNKNOWN CONTEXTUAL PROPERTY */
} else {
apdu_len = BACNET_STATUS_ERROR;
}
}
value->next = NULL;
else if ( tag_len == 1 ) /* and is a Closing tag */
apdu_len = 0; /* Don't advance over that closing tag. */
}
return apdu_len;