Fixed GetEvent initialization of linked list (#1026)

* Fixed GetEvent usage of linked list by initializing next in all the examples and unit test.

* Secured GetEventInformation encoders by accepting NULL for APDU for determining the size, and exploit the NULL APDU for size checking during encoding. Secured the GetEventInformation decoders and removed the use of deprecated decoder API.
This commit is contained in:
Steve Karg
2025-06-20 13:34:39 -05:00
committed by GitHub
parent b0a97c6f75
commit 14f033ceda
7 changed files with 498 additions and 300 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ void handler_get_event_information(
BACNET_ADDRESS my_address;
BACNET_OBJECT_ID object_id;
unsigned i = 0, j = 0; /* counter */
BACNET_GET_EVENT_INFORMATION_DATA getevent_data;
BACNET_GET_EVENT_INFORMATION_DATA getevent_data = { 0 };
int valid_event = 0;
/* initialize type of 'Last Received Object Identifier' using max value */
+5 -7
View File
@@ -42,20 +42,18 @@ void get_event_ack_handler(
BACNET_ADDRESS *src,
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
{
uint8_t i = 0;
uint16_t apdu_len = 0;
bool more_events = false;
/* initialize array big enough to accommodate
multiple get event data in APDU */
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS];
BACNET_GET_EVENT_INFORMATION_DATA get_event_data[MAX_NUMBER_OF_EVENTS] = {
0
};
(void)src;
(void)service_data;
for (i = 1; i < MAX_NUMBER_OF_EVENTS; i++) {
/* Create linked list */
get_event_data[i - 1].next = &get_event_data[i];
}
getevent_information_link_array(
&get_event_data[0], ARRAY_SIZE(get_event_data));
apdu_len = getevent_ack_decode_service_request(
&service_request[0], service_len, &get_event_data[0], &more_events);