Bugfix/service request refactor size check (#553)

* refactor service requests from service header

* add APDU size checking and length feature

* add unit tests to check for length when passing NULL buffer

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2024-01-05 08:59:45 -06:00
committed by GitHub
parent 5ca14e5320
commit bb081d28da
39 changed files with 2614 additions and 1514 deletions
+4 -4
View File
@@ -30,21 +30,21 @@ static int rd_decode_apdu(uint8_t *apdu,
int apdu_len = 0;
if (!apdu) {
return -1;
return BACNET_STATUS_ERROR;
}
if (apdu_size <= 4) {
return -1;
return BACNET_STATUS_ERROR;
}
/* optional checking - most likely was already done prior to this call */
if (apdu[0] != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
return -1;
return BACNET_STATUS_ERROR;
}
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
if (invoke_id) {
*invoke_id = apdu[2]; /* invoke id - filled in by net layer */
}
if (apdu[3] != SERVICE_CONFIRMED_REINITIALIZE_DEVICE) {
return -1;
return BACNET_STATUS_ERROR;
}
apdu_len = 4;
if (apdu_len < apdu_size) {