Bugfix/secure read range codec (#957)

* Secured ReadRange service codecs. Added ReadRange unit testing. Secured ReadRange-ACK handler to enable APDU size checking.
This commit is contained in:
Steve Karg
2025-04-03 09:14:08 -05:00
committed by GitHub
parent 921264b2c2
commit 31af2507fb
13 changed files with 828 additions and 440 deletions
+4 -4
View File
@@ -1517,8 +1517,7 @@ int decode_bitstring(
* @param apdu - buffer to hold the bytes
* @param apdu_size - number of bytes in the buffer to decode
* @param len_value - number of bytes in the unsigned value encoding
* @param value - value to decode into
*
* @param value - value to decode into, or NULL for length checking
* @return number of bytes decoded, or zero if errors occur
*/
int bacnet_bitstring_decode(
@@ -1533,7 +1532,7 @@ int bacnet_bitstring_decode(
uint32_t bytes_used;
/* check to see if the APDU is long enough */
if (apdu && value && (len_value <= apdu_size)) {
if (apdu && (len_value <= apdu_size)) {
/* Init/empty the string. */
bitstring_init(value);
if (len_value > 0) {
@@ -1544,7 +1543,8 @@ int bacnet_bitstring_decode(
/* Copy the bytes in reversed bit order. */
for (i = 0; i < bytes_used; i++) {
bitstring_set_octet(
value, (uint8_t)i, byte_reverse_bits(apdu[len++]));
value, (uint8_t)i, byte_reverse_bits(apdu[len]));
len++;
}
/* Erase the remaining unused bits. */
unused_bits = (uint8_t)(apdu[0] & 0x07);