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
+10 -9
View File
@@ -154,14 +154,16 @@ void handler_read_range(
len = Encode_RR_payload(&Temp_Buf[0], &data);
if (len >= 0) {
/* encode the APDU portion of the packet */
data.application_data = &Temp_Buf[0];
data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */
len = rr_ack_encode_apdu(
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
&data);
debug_print("RR: Sending Ack!\n");
error = false;
len = rr_ack_encode_apdu(NULL, service_data->invoke_id, &data);
if (len < sizeof(Handler_Transmit_Buffer) - pdu_len) {
len = rr_ack_encode_apdu(
&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, &data);
debug_print("RR: Sending Ack!\n");
error = false;
} else {
len = -2; /* too big */
}
}
if (error) {
if (len == -2) {
@@ -182,7 +184,6 @@ void handler_read_range(
}
}
}
pdu_len += len;
bytes_sent = datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);