Bugfix/read-range-address-list-encode (#1149)

* Fix: Corrected `rr_address_list_encode` to properly handle the end of the address cache and added a new test case to validate ReadRange operations near the cache limit.
This commit is contained in:
Steve Karg
2026-03-12 09:05:04 -05:00
committed by GitHub
parent 07bfc7c61c
commit f525e7c484
3 changed files with 94 additions and 16 deletions
+13 -3
View File
@@ -987,16 +987,26 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
/* Chalk up another one for the response count */
pRequest->ItemCount++;
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* valid entry at the end of the table */
uiLast = uiTotal;
break;
}
while ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) !=
BAC_ADDR_IN_USE) {
/* Find next bound entry */
pMatch++;
/* Can normally not happen. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* Issue with the table. */
return (0);
/* valid entry at the end of the table */
uiLast = uiTotal;
break;
}
}
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* valid entry at the end of the table */
uiLast = uiTotal;
break;
}
}
/* Set remaining result flags if necessary */
if (uiFirst == 1) {