So when trying to add response payload (ADPU) bigger than 1476 bytes, the validation with the max_offset goes through even though the size of the buffer is not big enough and we get an IndexOutOfRangeException.
Potential fix
As a first workaround, we tried to increase the max payload in the transport (here). But this has the side effect of causing IP fragmentation because now the packets are too big.
We also tried another fix in BacnetClient.EncodeSegmentHeader. This seems to fix the issue from our initial tests:
Couple of questions for you guys:
Does the fix makes sense?
Are there any tests we can run to validate we don't add regression to the library?
Issue
When calling ReadPropertyResponse, we get an IndexOutOfRangeException with the following stack trace:
How to reproduce
Investigation
From what we can see, because the request was coming from a BACnet router, the response need to add a bigger NPDU header and this would increase the max_offset of the buffer to a value higher than the actual size of the buffer as you can see here:
So when trying to add response payload (ADPU) bigger than 1476 bytes, the validation with the max_offset goes through even though the size of the buffer is not big enough and we get an IndexOutOfRangeException.
Potential fix
As a first workaround, we tried to increase the max payload in the transport (here). But this has the side effect of causing IP fragmentation because now the packets are too big.
We also tried another fix in BacnetClient.EncodeSegmentHeader. This seems to fix the issue from our initial tests:![image](https://user-images.githubusercontent.com/1434190/196578094-86806011-bafd-46cb-965b-a0e143fdc65a.png)
Couple of questions for you guys: